canDo('location.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('location.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('location.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('location.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; } } }