public function view(UserPolicy $user, Task $task)
    {
        if ($user->canDo('task.task.view') && $user->isAdmin()) {
            return true;
        }

        return $user->id == $task->user_id && get_class($user) === $task->user_type;
    }
public function view(UserPolicy $user, Task $task)
    {
        if ($user->canDo('task.task.view') && $user->isAdmin()) {
            return true;
        }

        return $user->id == $task->user_id && get_class($user) === $task->user_type;
    }
public function view ( UserPolicy $ user , Task $ task ) { if ( $ user -> canDo ( 'task.task.view' ) && $ user -> isAdmin ( ) ) { return true ; } return $ user -> id == $ task -> user_id && get_class ( $ user ) === $ task -> user_type ; }
Determine if the given user can view the task.

@param User $user
@param Task $task

@return bool
Determine if the given user can view the task .