Skip to content

Commit

Permalink
Bugfix Photo management
Browse files Browse the repository at this point in the history
  • Loading branch information
kreaweb.be committed Apr 13, 2024
1 parent d8f568f commit 2ef1cb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions app/Livewire/People/Edit/Photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function updatedPhotos(): void
$this->photos = collect($file)->unique(fn (UploadedFile $item) => $item->getClientOriginalName())->toArray();
}

public function savePhotos(): void
public function savePhotos()
{
// determine last index
$files = File::glob(public_path() . '/storage/photos/' . $this->person->team_id . '/' . $this->person->id . '_*.webp');
Expand Down Expand Up @@ -135,9 +135,11 @@ public function savePhotos(): void
}
}
}

return $this->redirect('/people/' . $this->person->id . '/edit-photos');
}

public function deletePhoto($photo): void
public function deletePhoto($photo)
{
Storage::disk('photos')->delete($this->person->team_id . '/' . $photo);

Expand All @@ -149,13 +151,17 @@ public function deletePhoto($photo): void
'photo' => $files ? substr($files[0], strrpos($files[0], '/') + 1) : null,
]);
}

return $this->redirect('/people/' . $this->person->id . '/edit-photos');
}

public function setPrimary($photo): void
public function setPrimary($photo)
{
$this->person->update([
'photo' => $photo,
]);

return $this->redirect('/people/' . $this->person->id . '/edit-photos');
}

public function render()
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/people/edit/photos.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>

<div class="p-4 bg-neutral-200 rounded-b">
<div class="grid grid-cols-3 gap-2">
<div class="grid grid-cols-2 sm:grid-cols-3 gap-2">
@foreach ($images as $image)
<x-ts-card class="!p-2">
<x-slot:header>
Expand Down

0 comments on commit 2ef1cb3

Please sign in to comment.