From ee6ac687c49d2035204d8bfee0abc9d841015d27 Mon Sep 17 00:00:00 2001 From: Phan An Date: Fri, 19 Oct 2018 16:33:04 +0200 Subject: [PATCH] Refactor the observers (#836) --- app/Observers/AlbumObserver.php | 5 +++++ app/Observers/SongObserver.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/Observers/AlbumObserver.php b/app/Observers/AlbumObserver.php index 8f6bd383..688921ef 100644 --- a/app/Observers/AlbumObserver.php +++ b/app/Observers/AlbumObserver.php @@ -16,6 +16,11 @@ class AlbumObserver } public function deleted(Album $album): void + { + $this->deleteAlbumCover($album); + } + + private function deleteAlbumCover(Album $album): void { if (!$album->has_cover) { return; diff --git a/app/Observers/SongObserver.php b/app/Observers/SongObserver.php index 711124c8..87901123 100644 --- a/app/Observers/SongObserver.php +++ b/app/Observers/SongObserver.php @@ -15,6 +15,11 @@ class SongObserver } public function creating(Song $song): void + { + $this->setFileHashAsId($song); + } + + private function setFileHashAsId(Song $song): void { $song->id = $this->helperService->getFileHash($song->path); }