canDo('location.city.view') && $authUser->isAdmin()) { return true; } return $city->user_id == user_id() && $city->user_type == user_type(); } /** * Determine if the given user can create a city. * * @param UserPolicyInterface $authUser * * @return bool */ public function create(UserPolicyInterface $authUser) { return $authUser->canDo('location.city.create'); } /** * Determine if the given user can update the given city. * * @param UserPolicyInterface $authUser * @param City $city * * @return bool */ public function update(UserPolicyInterface $authUser, City $city) { if ($authUser->canDo('location.city.edit') && $authUser->isAdmin()) { return true; } return $city->user_id == user_id() && $city->user_type == user_type(); } /** * Determine if the given user can delete the given city. * * @param UserPolicyInterface $authUser * * @return bool */ public function destroy(UserPolicyInterface $authUser, City $city) { return $city->user_id == user_id() && $city->user_type == user_type(); } /** * Determine if the given user can verify the given city. * * @param UserPolicyInterface $authUser * * @return bool */ public function verify(UserPolicyInterface $authUser, City $city) { if ($authUser->canDo('location.city.verify')) { return true; } return false; } /** * Determine if the given user can approve the given city. * * @param UserPolicyInterface $authUser * * @return bool */ public function approve(UserPolicyInterface $authUser, City $city) { if ($authUser->canDo('location.city.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $authUser [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($authUser, $ability) { if ($authUser->isSuperuser()) { return true; } } }