Skip to content

Commit

Permalink
Optimized Profile Livewire component
Browse files Browse the repository at this point in the history
  • Loading branch information
MGeurts committed Nov 6, 2024
1 parent db4e192 commit 2fb474c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/Livewire/People/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public function confirmDeletion(): void
public function deletePerson()
{
if ($this->person->isDeletable()) {
// delete all this person photos
File::delete(File::glob(storage_path('app/public/photos/' . $this->person->team_id . '/' . $this->person->id . '_*.webp')));
File::delete(File::glob(storage_path('app/public/photos-096/' . $this->person->team_id . '/' . $this->person->id . '_*.webp')));
File::delete(File::glob(storage_path('app/public/photos-384/' . $this->person->team_id . '/' . $this->person->id . '_*.webp')));
$this->deletePersonPhotos();

$this->person->delete();

Expand All @@ -47,6 +44,15 @@ public function deletePerson()
}
}

private function deletePersonPhotos(): void
{
$directories = ['photos', 'photos-096', 'photos-384'];

foreach ($directories as $directory) {
File::delete(File::glob(storage_path("app/public/{$directory}/" . $this->person->team_id . '/' . $this->person->id . '_*.webp')));
}
}

// ------------------------------------------------------------------------------
public function render(): View
{
Expand Down

0 comments on commit 2fb474c

Please sign in to comment.