- Comments and reply Comments
- Blacklist
- Moderation Mode
- Mode => 1 (Public): All comments will be public.
- Mode => 2 (Review comments on the blacklist): Comments that do not contain blacklisted words will be public. Otherwise, they will remain hidden
- Mode => 3 (Close): Comments will be created that do not contain blacklisted words. Otherwise, they will not be created
- Limit comment characters
- Limit number of links in a comment
- UrlLinker (convert text links to html)
From the command line:
composer require wimil/comments
Publish the config file:
php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=config
You can publish migration to allow you to have more control over your table
php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=migrations
We need to create the table for comments.
php artisan migrate
Add the Commenter
trait to your User model so that you can retrieve the comments for a user:
use Wimil\Comments\Commenter;
class User extends Authenticatable
{
use Notifiable, Commenter;
}
Add the Commentable
trait to the model for which you want to enable comments for:
use Wimil\Comments\Commentable;
class Product extends Model
{
use Commentable;
}
If you want to have your own Comment Model create a new one and extend my Comment model.
use Wimil\Comments\Model\Comment as BaseComment;
class Comment extends BaseComment
{
// ...
}
and dont forget to update the model name in the config/comment.php
file.
Comment package comes with several modes.
$user = App\User::first();
$product = App\Product::first();
// $user->comment(Commentable $model, $comment = '');
$user->comment($product, 'Lorem ipsum ..');