diff --git a/database/migrations/2025_12_12_000000_add_financial_fields_to_assets.php b/database/migrations/2025_12_12_000000_add_financial_fields_to_assets.php index 725054f..080f5f3 100644 --- a/database/migrations/2025_12_12_000000_add_financial_fields_to_assets.php +++ b/database/migrations/2025_12_12_000000_add_financial_fields_to_assets.php @@ -13,7 +13,7 @@ return new class extends Migration $table->unsignedInteger('useful_life_months')->nullable()->after('depreciation_method'); $table->decimal('residual_value', 15, 2)->nullable()->after('useful_life_months'); $table->string('capex_opex')->nullable()->after('residual_value'); // capex|opex - $table->foreignUuid('vendor_contract_id')->nullable()->after('capex_opex')->constrained('vendor_contracts')->nullOnDelete(); + $table->uuid('vendor_contract_id')->nullable()->after('capex_opex'); // FK opsional, tambahkan manual jika perlu $table->timestamp('warranty_reminder_sent_at')->nullable()->after('warranty_end'); }); } @@ -21,7 +21,6 @@ return new class extends Migration public function down(): void { Schema::table('assets', function (Blueprint $table) { - $table->dropForeign(['vendor_contract_id']); $table->dropColumn([ 'depreciation_method', 'useful_life_months', diff --git a/database/seeders/AssetSeeder.php b/database/seeders/AssetSeeder.php index 865283c..15912f0 100644 --- a/database/seeders/AssetSeeder.php +++ b/database/seeders/AssetSeeder.php @@ -10,6 +10,7 @@ use App\Models\AssetUser; use App\Models\AssetPhoto; use App\Models\Department; use App\Models\PersonInCharge; +use App\Models\VendorContract; use App\Models\Unit; use App\Models\Warranty; use App\Services\Asset\AssetService; @@ -32,6 +33,15 @@ class AssetSeeder extends Seeder $user = AssetUser::first(); $location = AssetLocation::first(); $warranty = Warranty::first(); + $contract = VendorContract::create([ + 'vendor_name' => 'Vendor Default', + 'contract_number' => 'CNT-001', + 'start_date' => now()->subMonths(6), + 'end_date' => now()->addMonths(6), + 'sla_response_hours' => 4, + 'sla_resolution_hours' => 24, + 'notes' => 'Kontrak default untuk sample aset', + ]); $names = [ 'Laptop Dell XPS 13', @@ -81,6 +91,11 @@ class AssetSeeder extends Seeder 'warranty_id' => $warranty?->id, 'purchase_date' => now()->subDays(30 + $index), 'cost' => 1000000 + ($index * 250000), + 'residual_value' => 500000, + 'useful_life_months' => 36, + 'depreciation_method' => $index % 2 === 0 ? 'straight_line' : 'diminishing', + 'capex_opex' => $index % 3 === 0 ? 'capex' : 'opex', + 'vendor_contract_id' => $contract->id, ]); // Download 2 foto berbeda untuk tiap aset dari pool.