added delete option

This commit is contained in:
Alexander Gabriel 2026-05-26 22:53:13 +02:00
parent 079f65bc5f
commit c900f1bf68
2 changed files with 18 additions and 1 deletions

View File

@ -11,6 +11,17 @@ class CameraCapture extends Component
{
public string $status = '';
public function delete(int $jobId): void
{
$job = PhotoJob::find($jobId);
if (!$job) return;
Storage::disk('public')->delete($job->image_path);
$job->delete();
$this->status = "Job #{$jobId} deleted";
}
public function capture(string $imageData): void
{
if (!preg_match('/^data:image\/(\w+);base64,/', $imageData, $type)) {

View File

@ -22,12 +22,18 @@
<h2 class="text-sm font-medium text-gray-400 mb-3 tracking-wide uppercase">Recent Photos</h2>
<div class="grid grid-cols-5 gap-2">
@foreach ($recentPhotos as $photo)
<div class="relative group">
<div class="relative">
<img src="{{ $photo['url'] }}" alt="Photo #{{ $photo['id'] }}"
class="w-full aspect-square object-cover rounded-lg border border-gray-700">
<span class="absolute bottom-1 left-1 text-[10px] px-1.5 py-0.5 rounded bg-black/60 text-yellow-400">
{{ $photo['status'] }}
</span>
<button wire:click="delete({{ $photo['id'] }})"
class="absolute top-1 right-1 p-1 rounded bg-black/60 text-white hover:bg-red-600/80 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd"/>
</svg>
</button>
</div>
@endforeach
</div>