From c3ce6e1d717a82c9109761d5acbecf79548844c8 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sun, 10 Sep 2017 17:21:52 +0100 Subject: [PATCH] Added album deletion policy --- app/Policies/AlbumPolicy.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Policies/AlbumPolicy.php b/app/Policies/AlbumPolicy.php index 4e069c8..38f007c 100644 --- a/app/Policies/AlbumPolicy.php +++ b/app/Policies/AlbumPolicy.php @@ -54,6 +54,23 @@ class AlbumPolicy return $this->userHasPermission($user, $album, $permission); } + public function delete(User $user, Album $album) + { + if ($user->id == $album->user_id) + { + // The album's owner and can do everything + return true; + } + + // Get the edit permission + $permission = Permission::where([ + 'section' => 'album', + 'description' => 'delete' + ])->first(); + + return $this->userHasPermission($user, $album, $permission); + } + public function deletePhotos(User $user, Album $album) { if ($user->id == $album->user_id)