is_admin) { // Admins can do anything return true; } } public function changeMetadata(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('change-photo-metadata', $photo->album); } public function delete(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('delete-photos', $photo->album); } public function manipulate(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('manipulate-photos', $photo->album); } public function moderateComments(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('moderate-comments', $photo->album); } public function postComment(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('post-comment', $photo->album); } public function view(User $user, Photo $photo) { if ($user->id == $photo->user_id) { // The photo's owner can do everything return true; } return $user->can('view', $photo->album); } }