canDo('test.plan.view') && $user->isAdmin()) { return true; } return $plan->user_id == user_id() && $plan->user_type == user_type(); } /** * Determine if the given user can create a plan. * * @param UserPolicy $user * @param Plan $plan * * @return bool */ public function create(UserPolicy $user) { return $user->canDo('test.plan.create'); } /** * Determine if the given user can update the given plan. * * @param UserPolicy $user * @param Plan $plan * * @return bool */ public function update(UserPolicy $user, Plan $plan) { if ($user->canDo('test.plan.edit') && $user->isAdmin()) { return true; } return $plan->user_id == user_id() && $plan->user_type == user_type(); } /** * Determine if the given user can delete the given plan. * * @param UserPolicy $user * @param Plan $plan * * @return bool */ public function destroy(UserPolicy $user, Plan $plan) { return $plan->user_id == user_id() && $plan->user_type == user_type(); } /** * Determine if the given user can verify the given plan. * * @param UserPolicy $user * @param Plan $plan * * @return bool */ public function verify(UserPolicy $user, Plan $plan) { if ($user->canDo('test.plan.verify')) { return true; } return false; } /** * Determine if the given user can approve the given plan. * * @param UserPolicy $user * @param Plan $plan * * @return bool */ public function approve(UserPolicy $user, Plan $plan) { if ($user->canDo('test.plan.approve')) { 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; } } }