canDo('visitor.visitor.view') && $user->isAdmin()) { return true; } return $visitor->user_id == user_id() && $visitor->user_type == user_type(); } /** * Determine if the given user can create a visitor. * * @param UserPolicy $user * @param Visitor $visitor * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('visitor.visitor.create'); } /** * Determine if the given user can update the given visitor. * * @param UserPolicy $user * @param Visitor $visitor * * @return bool */ public function update(UserPolicy $user, Visitor $visitor) { if ($user->canDo('visitor.visitor.edit') && $user->isAdmin()) { return true; } return $visitor->user_id == user_id() && $visitor->user_type == user_type(); } /** * Determine if the given user can delete the given visitor. * * @param UserPolicy $user * @param Visitor $visitor * * @return bool */ public function destroy(UserPolicy $user, Visitor $visitor) { return $visitor->user_id == user_id() && $visitor->user_type == user_type(); } /** * Determine if the given user can verify the given visitor. * * @param UserPolicy $user * @param Visitor $visitor * * @return bool */ public function verify(UserPolicy $user, Visitor $visitor) { if ($user->canDo('visitor.visitor.verify')) { return true; } return false; } /** * Determine if the given user can approve the given visitor. * * @param UserPolicy $user * @param Visitor $visitor * * @return bool */ public function approve(UserPolicy $user, Visitor $visitor) { if ($user->canDo('visitor.visitor.approve')) { 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; } } }