canDo('file_repository.notifications.view') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.view') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $notifications->user_id; } /** * Determine if the given user can create a notifications. * * @param User $user * @param Notifications $notifications * * @return bool */ public function create(User $user) { return $user->canDo('file_repository.notifications.create'); } /** * Determine if the given user can update the given notifications. * * @param User $user * @param Notifications $notifications * * @return bool */ public function update(User $user, Notifications $notifications) { if ($user->canDo('file_repository.notifications.update') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.update') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $notifications->user_id; } /** * Determine if the given user can delete the given notifications. * * @param User $user * @param Notifications $notifications * * @return bool */ public function destroy(User $user, Notifications $notifications) { if ($user->canDo('file_repository.notifications.delete') && $user->is('admin')) { return true; } if ($user->canDo('blocks.block.delete') && $user->is('manager') && $block->user->parent_id == $user->id) { return true; } return $user->id === $notifications->user_id; } /** * Determine if the given user can verify the given notifications. * * @param User $user * @param Notifications $notifications * * @return bool */ public function verify(User $user, Notifications $notifications) { if ($user->canDo('file_repository.notifications.verify') && $user->is('admin')) { return true; } if ($user->canDo('file_repository.notifications.verify') && $user->is('manager') && $notifications->user->parent_id == $user->id) { return true; } return false; } /** * Determine if the given user can approve the given notifications. * * @param User $user * @param Notifications $notifications * * @return bool */ public function approve(User $user, Notifications $notifications) { if ($user->canDo('file_repository.notifications.approve') && $user->is('admin')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $user [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($user, $ability) { if ($user->isSuperUser()) { return true; } } }