Download the PHP package bishalgurung/laravel-comment without Composer
On this page you can find all versions of the php package bishalgurung/laravel-comment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-comment
Installation
Installing the package
Exporting the migration files:
Migrating the tables
Seeding default reactions:
You can add more reactions by changing the "reactions" array in the comment.php config file and running comment:install again
Exporting the config file (optional):
The follwing will publish the config file below
Associate comments with Eloquent models
This package allows your models the ability to have comments associated to it.
Here's a small example of how to add comment to your model.
Lets say you have a Post model. In order to make it commentable, you just attach the HasComment trait to it
Now to add a comment, just use:
By default, the logged in user will be set as the user_type and userid in the comments_ table. But you can change that by using:
If you want to retrieve all the comments of a post, use:
Attach reaction to an Eloquent model
You can also attach reaction to any model. For that, just use:
Now to add a reaction to a model, just use:
Now to retrieve the reaction counts along with the Post model, we use:
This will return reaction count attached to Post collection as below:
Attach reply to a comment
If you take a look at the comment model in the vendor/bishalgurung/laravel-comment/src/Models/Comment.php file, you will notice that the Comment model also uses the HasComment trait. Which means that you can comment on a comment model. So a comment on a comment model is a reply, and this is how you use the reply system.
And to get replies, just use:
Upcoming feature
- Custom icons for your reaction