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