fix(attendance): memperbaiki logika save image dan menampilkan image

This commit is contained in:
Yoga Pangestu 2024-12-03 21:44:01 +07:00
parent 0dea36d1cb
commit 4715a1dfce
2 changed files with 5 additions and 6 deletions

View File

@ -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([

View File

@ -43,9 +43,9 @@
@if ($checkInAttendance)
<div class="flex-shrink-0">
<a
href="{{ Storage::url("attendances/{$checkInAttendance->attachments->first()->formatted_attachment}") }}">
href="{{ Storage::url("attendances/{$checkInAttendance->attachments->where('type', 'check_in')->first()->formatted_attachment}") }}">
<img class="tab-img img-fluid"
src="{{ Storage::url("attendances/{$checkInAttendance->attachments->first()->formatted_attachment}") }}"
src="{{ Storage::url("attendances/{$checkInAttendance->attachments->where('type', 'check_in')->first()->formatted_attachment}") }}"
alt="image">
</a>
</div>
@ -84,9 +84,9 @@
@if ($checkOutAttendance)
<div class="flex-shrink-0">
<a
href="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->latest()->first()->formatted_attachment}") }}">
href="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->where('type', 'check_out')->first()->formatted_attachment}") }}">
<img class="tab-img img-fluid"
src="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->latest()->first()->formatted_attachment}") }}"
src="{{ Storage::url("attendances/{$checkOutAttendance->attachments()->where('type', 'check_out')->first()->formatted_attachment}") }}"
alt="image">
</a>
</div>