From 4715a1dfcec4c36b852738cf3cedd5e0213a406c Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 3 Dec 2024 21:44:01 +0700 Subject: [PATCH] fix(attendance): memperbaiki logika save image dan menampilkan image --- .../Controllers/Admin/Manage/AttendanceController.php | 3 +-- resources/views/pages/admin/manage/attendances.blade.php | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/Manage/AttendanceController.php b/app/Http/Controllers/Admin/Manage/AttendanceController.php index 65cf5c9..930e621 100644 --- a/app/Http/Controllers/Admin/Manage/AttendanceController.php +++ b/app/Http/Controllers/Admin/Manage/AttendanceController.php @@ -105,8 +105,7 @@ public function store(AttendanceRequest $request): JsonResponse 'check_out' => now(), ]); } - - $this->uploadAttachment($validatedData['image'], 'attendances', Attendance::class, $newAttendance->id, 'attendance'); + $this->uploadAttachment($validatedData['image'], 'attendances', Attendance::class, $newAttendance->id, ! $checkInAttendance ? 'check_in' : 'check_out'); }); return response()->json([ diff --git a/resources/views/pages/admin/manage/attendances.blade.php b/resources/views/pages/admin/manage/attendances.blade.php index 2d39c9e..cf8af9e 100644 --- a/resources/views/pages/admin/manage/attendances.blade.php +++ b/resources/views/pages/admin/manage/attendances.blade.php @@ -43,9 +43,9 @@ @if ($checkInAttendance)
attachments->first()->formatted_attachment}") }}"> + href="{{ Storage::url("attendances/{$checkInAttendance->attachments->where('type', 'check_in')->first()->formatted_attachment}") }}"> attachments->first()->formatted_attachment}") }}" + src="{{ Storage::url("attendances/{$checkInAttendance->attachments->where('type', 'check_in')->first()->formatted_attachment}") }}" alt="image">
@@ -84,9 +84,9 @@ @if ($checkOutAttendance)
attachments()->latest()->first()->formatted_attachment}") }}"> + href="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->where('type', 'check_out')->first()->formatted_attachment}") }}"> attachments()->latest()->first()->formatted_attachment}") }}" + src="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->where('type', 'check_out')->first()->formatted_attachment}") }}" alt="image">