Skip to content
Simple way to add comments to your Laravel Eloquent models
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
migrations
src
tests
.editorconfig
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE.md
README.md
composer.json
phpunit.xml.dist

README.md

Simple way to add comments to your Laravel Eloquent models

Latest Version on Packagist Build Status Quality Score Total Downloads

Installation

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

Usage

Just add HasComments trait to the eloquent model.

...
class Post extends Model
{
    use HasComments;
    ...
}

Creating Comments

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);

Retrieving Comments

To get list of comments you can use comments method.

$post = Post::find(1);

$post->comments;

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email axitdev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.