public function commentAsUser(?Model $user, string $comment)
    {
        $commentClass = config('comments.comment_class');

        $comment = new $commentClass([
            'comment' => $comment,
            'is_approved' => ($user instanceof Commentator) ? ! $user->needsCommentApproval($this) : false,
            'user_id' => is_null($user) ? null : $user->getKey(),
            'commentable_id' => $this->getKey(),
            'commentable_type' => get_class(),
        ]);

        return $this->comments()->save($comment);
    }
public function commentAsUser(?Model $user, string $comment)
    {
        $commentClass = config('comments.comment_class');

        $comment = new $commentClass([
            'comment' => $comment,
            'is_approved' => ($user instanceof Commentator) ? ! $user->needsCommentApproval($this) : false,
            'user_id' => is_null($user) ? null : $user->getKey(),
            'commentable_id' => $this->getKey(),
            'commentable_type' => get_class(),
        ]);

        return $this->comments()->save($comment);
    }
public function commentAsUser ( ? Model $ user , string $ comment ) { $ commentClass = config ( 'comments.comment_class' ) ; $ comment = new $ commentClass ( [ 'comment' => $ comment , 'is_approved' => ( $ user instanceof Commentator ) ? ! $ user -> needsCommentApproval ( $ this ) : false , 'user_id' => is_null ( $ user ) ? null : $ user -> getKey ( ) , 'commentable_id' => $ this -> getKey ( ) , 'commentable_type' => get_class ( ) , ] ) ; return $ this -> comments ( ) -> save ( $ comment ) ; }
Attach a comment to this model as a specific user.

@param Model|null $user
@param string $comment
@return \Illuminate\Database\Eloquent\Model
Attach a comment to this model as a specific user .