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