Simple way to add comments to your Laravel Eloquent models
axitdev/laravelfastcomments is a Laravel package for simple way to add comments to your laravel eloquent models.
It currently has 0 GitHub stars and 64 downloads on Packagist (latest version v1.0.0).
Install it with composer require axitdev/laravelfastcomments.
Discover more Laravel packages by axitdev
or browse all Laravel packages to compare alternatives.
Last updated
You can install the package via composer:
composer require axitdev/laravelfastcomments
Publish the migration:
php artisan vendor:publish --provider="Axitdev\LaravelFastComments\LaravelFastCommentsServiceProvider"
And don't forget to migrate:
php artisan migrate
Just add HasComments trait to the eloquent model.
...
class Post extends Model
{
use HasComments;
...
}
To create new comment you can use comment method.
$post = Post::find(1);
$post->comment('Comment text');
By default comment method will create a comment with user_id from auth()->user()->id, but you can create comment as another user.
$user = User::find(1);
$post = Post::find(1);
$post->comment('Comment text', $user);
To get list of comments you can use comments method.
$post = Post::find(1);
$post->comments;
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.