canDo('task.task.view') && $authUser->isAdmin()) { return true; } return $task->user_id == user_id() && $task->user_type == user_type(); } /** * Determine if the given user can create a task. * * @param UserPolicyInterface $authUser * * @return bool */ public function create(UserPolicyInterface $authUser) { return $authUser->canDo('task.task.create'); } /** * Determine if the given user can update the given task. * * @param UserPolicyInterface $authUser * @param Task $task * * @return bool */ public function update(UserPolicyInterface $authUser, Task $task) { if ($authUser->canDo('task.task.edit') && $authUser->isAdmin()) { return true; } return $task->user_id == user_id() && $task->user_type == user_type(); } /** * Determine if the given user can delete the given task. * * @param UserPolicyInterface $authUser * * @return bool */ public function destroy(UserPolicyInterface $authUser, Task $task) { return $task->user_id == user_id() && $task->user_type == user_type(); } /** * Determine if the given user can verify the given task. * * @param UserPolicyInterface $authUser * * @return bool */ public function verify(UserPolicyInterface $authUser, Task $task) { if ($authUser->canDo('task.task.verify')) { return true; } return false; } /** * Determine if the given user can approve the given task. * * @param UserPolicyInterface $authUser * * @return bool */ public function approve(UserPolicyInterface $authUser, Task $task) { if ($authUser->canDo('task.task.approve')) { return true; } return false; } /** * Determine if the user can perform a given action ve. * * @param [type] $authUser [description] * @param [type] $ability [description] * * @return [type] [description] */ public function before($authUser, $ability) { if ($authUser->isSuperuser()) { return true; } } }