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