wimil / comments
Comments for Laravel.
dev-master
2019-09-25 23:46 UTC
Requires
- php: ^7.1.3|^7.2
- illuminate/database: ^5.6|^6.0
- illuminate/support: ^5.6|^6.0
This package is auto-updated.
Last update: 2025-01-29 06:13:49 UTC
README
Features
- 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)
Installation
From the command line:
composer require wimil/comments
Publish Config & configure
Publish the config file:
php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=config
Publish Migrations
You can publish migration to allow you to have more control over your table
php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=migrations
Run migrations
We need to create the table for comments.
php artisan migrate
Add Commenter trait to your Model
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 Commentable trait to models
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.
Usage
$user = App\User::first(); $product = App\Product::first(); // $user->comment(Commentable $model, $comment = ''); $user->comment($product, 'Lorem ipsum ..');