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