diff --git a/app/Models/Permohonan.php b/app/Models/Permohonan.php index 60c9303..a3b35c1 100644 --- a/app/Models/Permohonan.php +++ b/app/Models/Permohonan.php @@ -2,6 +2,7 @@ namespace Modules\Lpj\Models; +use Illuminate\Support\Facades\Storage; use Modules\Lpj\Database\Factories\PermohonanFactory; use Modules\Lpj\Services\PermohonanHistoryService; use Modules\Usermanagement\Models\User; @@ -39,7 +40,6 @@ class Permohonan extends Base 'registrasi_at', 'jenis_penilaian_id', 'region_id', - 'attachment' ]; protected static function boot() @@ -70,12 +70,7 @@ class Permohonan extends Base $fileName = time() . '_' . $file->getClientOriginalName(); $filePath = $file->storeAs('permohonan_attachments', $fileName, 'public'); - // Delete old file if it exists - if ($permohonan->attachment) { - Storage::disk('public')->delete($permohonan->attachment); - } - - $permohonan->attachment = $filePath; + $permohonan->dokumen = $filePath; } } @@ -87,7 +82,7 @@ class Permohonan extends Base $keterangan = request()->input('keterangan'); // Get keterangan from request $beforeRequest = $action === 'updated' ? $permohonan->getOriginal() : []; $afterRequest = $permohonan->toArray(); - $file = $permohonan->attachment ? Storage::disk('public')->path($permohonan->attachment) : null; + $file = $permohonan->dokumen ? Storage::disk('public')->path($permohonan->dokumen) : null; $historyService->createHistory( $permohonan, diff --git a/app/Services/PermohonanHistoryService.php b/app/Services/PermohonanHistoryService.php index 783d41b..3b9e60c 100644 --- a/app/Services/PermohonanHistoryService.php +++ b/app/Services/PermohonanHistoryService.php @@ -7,15 +7,8 @@ use Modules\Lpj\Models\PermohonanHistory; class PermohonanHistoryService { - public function createHistory(Permohonan $permohonan, string $status, ?string $keterangan, array $beforeRequest, array $afterRequest, ?string $file = null) + public function createHistory(Permohonan $permohonan, string $status, ?string $keterangan, array $beforeRequest, array $afterRequest, ?string $filePath = null) { - - $filePath = null; - if ($file) { - $filePath = $file->store('permohonan_history_files', 'public'); - } - - try { $history = PermohonanHistory::create([ 'permohonan_id' => $permohonan->id, diff --git a/resources/views/permohonan/authorization/show.blade.php b/resources/views/permohonan/authorization/show.blade.php index bd40825..193999a 100644 --- a/resources/views/permohonan/authorization/show.blade.php +++ b/resources/views/permohonan/authorization/show.blade.php @@ -9,7 +9,7 @@ @include('lpj::component.detail-jaminan',['backLink' => 'authorization.index'])