morphMany(Comment::class, 'commentable'); } public function comment(string $comment) { return $this->commentAsUser(auth()->user(), $comment); } public function commentAsUser(?Model $user, string $comment) { $comment = new Comment([ '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); } }