src/Policies/MessagePolicy.php
public function view(UserPolicy $user, Message $message)
    {
        if ($user->canDo('message.message.view') && $user->hasRole('admin')) {
            return true;
        }

        return $user->id == $message->user_id && get_class($user) == $message->user_type;
    }
public function view(UserPolicy $user, Message $message)
    {
        if ($user->canDo('message.message.view') && $user->hasRole('admin')) {
            return true;
        }

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

@param User $user
@param Message $message

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