2025-12-01 09:30:58 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Models\Asset;
|
|
|
|
|
use App\Services\Asset\AssetService;
|
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class AssetAuditController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(private readonly AssetService $assets)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function store(Request $request, Asset $asset): RedirectResponse
|
|
|
|
|
{
|
2025-12-02 09:54:56 +07:00
|
|
|
abort_unless($asset->isVisibleTo($request->user()), 403);
|
2025-12-01 09:30:58 +07:00
|
|
|
$data = $request->validate([
|
|
|
|
|
'status' => ['required', 'string', 'in:matched,missing,damaged'],
|
|
|
|
|
'notes' => ['nullable', 'string'],
|
|
|
|
|
'location_id' => ['nullable', 'uuid', 'exists:asset_locations,id'],
|
|
|
|
|
'audited_at' => ['nullable', 'date'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->assets->audit($asset, $data);
|
|
|
|
|
|
|
|
|
|
return back()->with('success', 'Audit aset berhasil dicatat.');
|
|
|
|
|
}
|
|
|
|
|
}
|