Add Comments to your Laravel Application with the Commenter Package

The Commenter package for Laravel "is a feature-rich modern package that addresses all your commenting needs in a Laravel application." The package includes an admin panel to manage comments across all "commentable" models.

Commenter demo project example
Commenter demo project example

The package models include a Commenter, and a Commentable model. You can use this package with your Eloquent models by implementing the CommentableContract and CommenterContract interfaces. The following example illustrates that Post is commentable, and User is a commenter:

use LakM\Comments\Concerns\Commentable;
use LakM\Comments\Contracts\CommentableContract;

class Post extends Model implements CommentableContract
{
    use Commentable;
}

And the Commentable interface on the User model, for example:

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use LakM\Comments\Concerns\Commenter;

class User extends Authenticatable
{
    use HasFactory, Notifiable, Commenter;
}

Commenter features:

To get started with this package, I recommend reading the Commenter documentation. You can view the source code on GitHub, and the package author also has a demo project to get a basic overview of this package.


The post Add Comments to your Laravel Application with the Commenter Package appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.