diff --git a/app/Http/Controllers/AssetTransactionController.php b/app/Http/Controllers/AssetTransactionController.php index 83e084a..1916c59 100644 --- a/app/Http/Controllers/AssetTransactionController.php +++ b/app/Http/Controllers/AssetTransactionController.php @@ -19,6 +19,7 @@ class AssetTransactionController extends Controller $data = $request->validate([ 'to_location_id' => ['nullable', 'uuid', 'exists:asset_locations,id'], 'to_department_id' => ['nullable', 'uuid', 'exists:departments,id'], + 'to_asset_user_id' => ['nullable', 'uuid', 'exists:asset_users,id'], 'notes' => ['nullable', 'string'], 'performed_at' => ['nullable', 'date'], ]); diff --git a/app/Models/AssetMovement.php b/app/Models/AssetMovement.php index 06c9ee2..3e63680 100644 --- a/app/Models/AssetMovement.php +++ b/app/Models/AssetMovement.php @@ -16,6 +16,8 @@ class AssetMovement extends Model 'to_location_id', 'from_department_id', 'to_department_id', + 'from_asset_user_id', + 'to_asset_user_id', 'notes', 'moved_by', 'performed_at', @@ -49,4 +51,14 @@ class AssetMovement extends Model { return $this->belongsTo(Department::class, 'to_department_id'); } + + public function fromUser() + { + return $this->belongsTo(AssetUser::class, 'from_asset_user_id'); + } + + public function toUser() + { + return $this->belongsTo(AssetUser::class, 'to_asset_user_id'); + } } diff --git a/app/Services/Asset/AssetService.php b/app/Services/Asset/AssetService.php index 307b443..83ede0f 100644 --- a/app/Services/Asset/AssetService.php +++ b/app/Services/Asset/AssetService.php @@ -112,6 +112,8 @@ class AssetService 'to_location_id' => $data['to_location_id'] ?? null, 'from_department_id' => $asset->department_id, 'to_department_id' => $data['to_department_id'] ?? null, + 'from_asset_user_id' => $asset->asset_user_id, + 'to_asset_user_id' => $data['to_asset_user_id'] ?? null, 'notes' => $data['notes'] ?? null, 'moved_by' => auth()->id(), 'performed_at' => $data['performed_at'] ?? now(), @@ -120,6 +122,7 @@ class AssetService $asset->update([ 'asset_location_id' => $data['to_location_id'] ?? $asset->asset_location_id, 'department_id' => $data['to_department_id'] ?? $asset->department_id, + 'asset_user_id' => $data['to_asset_user_id'] ?? $asset->asset_user_id, ]); $this->logHistory($asset, 'movement', 'Perpindahan aset', $movement->toArray()); diff --git a/database/migrations/2025_12_05_000000_add_user_to_asset_movements.php b/database/migrations/2025_12_05_000000_add_user_to_asset_movements.php new file mode 100644 index 0000000..f7b8fb9 --- /dev/null +++ b/database/migrations/2025_12_05_000000_add_user_to_asset_movements.php @@ -0,0 +1,24 @@ +foreignUuid('from_asset_user_id')->nullable()->after('from_department_id')->constrained('asset_users')->nullOnDelete(); + $table->foreignUuid('to_asset_user_id')->nullable()->after('from_asset_user_id')->constrained('asset_users')->nullOnDelete(); + }); + } + + public function down(): void + { + Schema::table('asset_movements', function (Blueprint $table) { + $table->dropConstrainedForeignId('from_asset_user_id'); + $table->dropConstrainedForeignId('to_asset_user_id'); + }); + } +}; diff --git a/resources/views/assets/show.blade.php b/resources/views/assets/show.blade.php index 24da211..4ce2049 100644 --- a/resources/views/assets/show.blade.php +++ b/resources/views/assets/show.blade.php @@ -70,7 +70,7 @@
@csrf
-
+
-
+
+
+ + +
@@ -112,10 +121,10 @@ {{ optional($movement->performed_at)->format('d/m/Y H:i') ?: '-' }} - {{ $movement->fromLocation?->name ?: '-' }} / {{ $movement->fromDepartment?->name ?: '-' }} + {{ $movement->fromLocation?->name ?: '-' }} / {{ $movement->fromDepartment?->name ?: '-' }} / {{ $movement->fromUser?->name ?: '-' }} - {{ $movement->toLocation?->name ?: '-' }} / {{ $movement->toDepartment?->name ?: '-' }} + {{ $movement->toLocation?->name ?: '-' }} / {{ $movement->toDepartment?->name ?: '-' }} / {{ $movement->toUser?->name ?: '-' }} {{ $movement->notes ?: '-' }} diff --git a/resources/views/layouts/components/main-sidebar.blade.php b/resources/views/layouts/components/main-sidebar.blade.php index 432a2a3..cad48be 100644 --- a/resources/views/layouts/components/main-sidebar.blade.php +++ b/resources/views/layouts/components/main-sidebar.blade.php @@ -104,7 +104,7 @@
  • Kelas Aset
  • Satuan
  • Departemen
  • -
  • Penanggung Jawab
  • +
  • Penanggung Jawab (Person in Charge)
  • Pengguna Aset
  • Kategori Aset
  • Lokasi Aset
  • diff --git a/routes/web.php b/routes/web.php index a7eff43..2f315a0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -42,7 +42,7 @@ Route::resource('asset-statuses', AssetStatusController::class)->only(['index', Route::resource('asset-classes', AssetClassController::class)->only(['index', 'store', 'update', 'destroy']); Route::resource('units', UnitController::class)->only(['index', 'store', 'update', 'destroy']); Route::resource('departments', DepartmentController::class)->only(['index', 'store', 'update', 'destroy']); -Route::resource('people-in-charge', PersonInChargeController::class)->only(['index', 'store', 'update', 'destroy']); +Route::resource('person-in-charge', PersonInChargeController::class)->only(['index', 'store', 'update', 'destroy']); Route::resource('asset-users', AssetUserController::class)->only(['index', 'store', 'update', 'destroy']); Route::resource('asset-categories', AssetCategoryController::class)->only(['index', 'store', 'update', 'destroy']); Route::resource('asset-locations', AssetLocationController::class)->only(['index', 'store', 'update', 'destroy']);