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