Downloads
Stars
Version
This package provides adding comments to any of your existing Eloquent models.
You can install the package via composer:
composer require orkhanahmadov/laravel-commentable
Publish migration and config files:
php artisan vendor:publish --provider="Orkhanahmadov\LaravelCommentable\LaravelCommentableServiceProvider"
Config file contains following settings:
table_name
- here you are set table name for migration. Default is "comments".Use Orkhanahmadov\LaravelCommentable\Commentable
trait in any of your existing Eloquent model to make it commentable.
use Illuminate\Database\Eloquent\Model;
use Orkhanahmadov\LaravelCommentable\Commentable;
class Post extends Model
{
use Commentable;
}
To add a comment to your model call comment()
method from model instance.
$post = Post::find(1);
$post->comment('Great post, thanks for sharing!');
To add a comment as a user call commentAs()
method from model instance.
$post = Post::find(1);
$user = User::find(5);
$post->commentAs($user, 'Great post, thanks for sharing!');
Each comment also saves IP address, User-Agent from request.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.