canDo('messenger_user.messenger_user.view') && $user->is('admin')) { return true; } return $user->id === $messenger_user->user_id; } /** * Determine if the given user can create a messenger_user. * * @param User $user * @param MessengerUser $messenger_user * * @return bool */ public function create(User $user) { return $user->canDo('messenger_user.messenger_user.create'); } /** * Determine if the given user can update the given messenger_user. * * @param User $user * @param MessengerUser $messenger_user * * @return bool */ public function update(User $user, MessengerUser $messenger_user) { if ($user->canDo('messenger_user.messenger_user.update') && $user->is('admin')) { return true; } return $user->id === $messenger_user->user_id; } /** * Determine if the given user can delete the given messenger_user. * * @param User $user * @param MessengerUser $messenger_user * * @return bool */ public function destroy(User $user, MessengerUser $messenger_user) { if ($user->canDo('messenger_user.messenger_user.delete') && $user->is('admin')) { return true; } return $user->id === $messenger_user->user_id; } /** * 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; } } }