canDo('country.country.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 === $country->user_id; } /** * Determine if the given user can create a country. * * @param UserPolicy $user * @param Country $country * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('country.country.create'); } /** * Determine if the given user can update the given country. * * @param UserPolicy $user * @param Country $country * * @return bool */ public function update(UserPolicy $user, Country $country) { if ($user->canDo('country.country.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 === $country->user_id; } /** * Determine if the given user can delete the given country. * * @param UserPolicy $user * @param Country $country * * @return bool */ public function destroy(UserPolicy $user, Country $country) { if ($user->canDo('country.country.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 === $country->user_id; } /** * Determine if the given user can verify the given country. * * @param UserPolicy $user * @param Country $country * * @return bool */ public function verify(UserPolicy $user, Country $country) { if ($user->canDo('country.country.verify') && $user->is('admin')) { return true; } if ($user->canDo('country.country.verify') && $user->is('manager') && $country->user->parent_id == $user->id) { return true; } return false; } /** * Determine if the given user can approve the given country. * * @param UserPolicy $user * @param Country $country * * @return bool */ public function approve(UserPolicy $user, Country $country) { if ($user->canDo('country.country.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; } } }