The Laravel Comments package by Ryan Chandler is a dead-simple package for adding comments to models in Laravel. Using the HasComments
trait on your models, you can quickly add comments attributed to users:
1use RyanChandler\Comments\Concerns\HasComments;2 3class Post extends Model4{5 use HasComments;6}
Given a post model, you can add a comment using the following method:
1$post = Post::first();2 3$post->comment('Hello, world!');
The above example is automatically attributed to the logged-in user. You can also assign a comment to a specific user:
1$post->comment('Hello, world!', user: $user);
This package also supports comment parent threads, meaning a comment can belong to another comment.
You can learn about this package, get full installation instructions, and view the source code on GitHub.