public function getComments(bool $nested = false)
    {
        $comments = $this->comments()->get();
        
        // If at least one comment is left by a registered user
        if ($comments->firstWhere('user_id', '>', 'null')) {
            $comments->load(['user:users.id,users.name,users.email,users.avatar']);
        }

        return $comments->treated($nested, $this->getAttributes());
    }
public function getComments(bool $nested = false)
    {
        $comments = $this->comments()->get();
        
        // If at least one comment is left by a registered user
        if ($comments->firstWhere('user_id', '>', 'null')) {
            $comments->load(['user:users.id,users.name,users.email,users.avatar']);
        }

        return $comments->treated($nested, $this->getAttributes());
    }
public function getComments ( bool $ nested = false ) { $ comments = $ this -> comments ( ) -> get ( ) ; // If at least one comment is left by a registered user if ( $ comments -> firstWhere ( 'user_id' , '>' , 'null' ) ) { $ comments -> load ( [ 'user:users.id,users.name,users.email,users.avatar' ] ) ; } return $ comments -> treated ( $ nested , $ this -> getAttributes ( ) ) ; }
Get a list comments with user relation, if need

@param boolean $nested
@return mixed Collection
Get a list comments with user relation if need