Simple Comments Package for Laravel
Published on by Paul Redmond
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:
use RyanChandler\Comments\Concerns\HasComments; class Post extends Model{ use HasComments;}
Given a post model, you can add a comment using the following method:
$post = Post::first(); $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:
$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.