1
0

sample about material

This commit is contained in:
Wian Drs
2026-06-23 16:04:37 +07:00
parent b52e67c428
commit faab64e0dd
16 changed files with 848 additions and 0 deletions
@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('technician_materials', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('barcode_id')->unique();
$table->unsignedBigInteger('inventory_item_id')->nullable();
$table->string('material_name');
$table->string('serial_number')->nullable();
$table->enum('status', [
'assigned',
'used',
'returned',
'lost',
'damaged'
])->default('assigned');
$table->dateTime('assigned_at');
$table->unsignedBigInteger('assigned_by')->nullable();
$table->timestamps();
$table->index('user_id');
$table->index('barcode_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('technician_materials');
}
};
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('technician_consumables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('barcode_id')->unique();
$table->unsignedBigInteger('inventory_item_id')->nullable();
$table->string('material_name');
$table->string('unit')->default('meter');
$table->decimal('qty_received', 10, 2)->default(0);
$table->decimal('qty_used', 10, 2)->default(0);
$table->decimal('qty_remaining', 10, 2)->default(0);
$table->dateTime('assigned_at');
$table->unsignedBigInteger('assigned_by')->nullable();
$table->timestamps();
$table->index('user_id');
$table->index('barcode_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('technician_consumables');
}
};
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ticket_consumables', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('technician_consumable_id');
$table->string('barcode_id');
$table->string('material_name');
$table->decimal('qty_used', 10, 2);
$table->string('unit')->default('meter');
$table->dateTime('used_at');
$table->timestamps();
$table->index('ticket_id');
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_consumables');
}
};
@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('material_movements', function (Blueprint $table) {
$table->id();
$table->string('barcode_id');
$table->unsignedBigInteger('user_id')->nullable();
$table->unsignedBigInteger('from_user_id')->nullable();
$table->unsignedBigInteger('to_user_id')->nullable();
$table->unsignedBigInteger('ticket_id')->nullable();
$table->enum('movement_type', [
'assign',
'transfer',
'use',
'return',
'lost',
'damaged'
]);
$table->decimal('qty', 10, 2)->nullable();
$table->text('description')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->dateTime('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('material_movements');
}
};
@@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('ticket_materials', function (Blueprint $table) {
if (!Schema::hasColumn('ticket_materials', 'user_id')) {
$table->unsignedBigInteger('user_id')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'technician_material_id')) {
$table->unsignedBigInteger('technician_material_id')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'barcode_id')) {
$table->string('barcode_id')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'serial_number')) {
$table->string('serial_number')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'used_at')) {
$table->dateTime('used_at')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'ticket_log_id')) {
$table->unsignedBigInteger('ticket_log_id')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'qty')) {
$table->decimal('qty', 12, 2)->default(1);
}
if (!Schema::hasColumn('ticket_materials', 'notes')) {
$table->text('notes')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'created_at')) {
$table->timestamp('created_at')->nullable();
}
if (!Schema::hasColumn('ticket_materials', 'updated_at')) {
$table->timestamp('updated_at')->nullable();
}
});
}
public function down(): void
{
Schema::table('ticket_materials', function (Blueprint $table) {
$table->dropColumn([
'user_id',
'technician_material_id',
'barcode_id',
'serial_number',
'used_at',
'ticket_log_id',
'qty',
'notes'
]);
});
}
};
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('technician_consumables', function (Blueprint $table) {
// kalau sebelumnya status belum ada
$table->enum('status', [
'assigned',
'used',
'returned',
'lost',
'damaged'
])->default('assigned')->after('qty_remaining');
$table->index('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('technician_consumables', function (Blueprint $table) {
$table->dropIndex(['status']);
$table->dropColumn('status');
});
}
};