Download the PHP package ftechstack/comments without Composer
On this page you can find all versions of the php package ftechstack/comments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ftechstack/comments
More information about ftechstack/comments
Files in ftechstack/comments
Informations about the package comments
Comments
Comments is a Laravel package. With it you can easily implement native comments for your application.
Overview
This package can be used to comment on any model you have in your application.
All comments are stored in a single table with a polymorphic relation for content and a polymorphic relation for the user who posted the comment.
Features
- [x] View comments
- [x] Create comments
- [x] Delete comments
- [x] Edit comments
- [x] Reply to comments
- [x] Authorization rules
- [x] Support localization
- [x] Dispatch events
- [x] Route, Controller, Comment, Migration & View customizations
- [x] Support for non-integer IDs
- [x] Support for multiple User models
- [x] Solved N+1 query problem
- [x] Comment approval (opt-in)
- [x] Guest commenting
Screenshots
Here are a few screenshots.
No comments & guest:
No comments & logged in:
One comment:
One comment edit form:
Two comments from different users:
Tutorials & articles
I plan to expand this chapter with more tutorials and articles. If you write something about this package let me know, so that I can update this chapter.
Articles:
Installation
From the command line:
Run migrations
We need to create the table for comments.
Add Commenter trait to your User model
Add the Commenter
trait to your User model so that you can retrieve the comments for a user:
Add Commentable trait to models
Add the Commentable
trait to the model for which you want to enable comments for:
Publish Config & configure (optional)
Publish the config file (optional):
Publish views (customization)
The default UI is made for Bootstrap 4, but you can change it however you want.
Publish Migrations (customization)
You can publish migration to allow you to have more control over your table
Usage
In the view where you want to display comments, place this code and modify it:
In the example above we are setting the commentable_type
to the class of the book. We are also passing the commentable_id
the id
of the book so that we know to which book the comments relate to. Behind the scenes, the package detects the currently logged in user if any.
If you open the page containing the view where you have placed the above code, you should see a working comments form.
View only approved comments
To view only approved comments, use this code:
Events
This package fires events to let you know when things happen.
Laravelista\Comments\Events\CommentCreated
Laravelista\Comments\Events\CommentUpdated
Laravelista\Comments\Events\CommentDeleted
REST API
To change the controller or the routes, see the config.
POST /comments
Request data:
PUT /comments/{comment}
- {comment} - Comment ID.
Request data:
POST /comments/{comment}
- {comment} - Comment ID.
Request data:
Updating from older versions
Support for guest commenting
If you are updating an already existing database table comments
and want support for guest commenting (new installations get this by default), then create a new migration with php artisan make:migration add_guest_commenting_columns_to_comments_table
and paste this code inside:
Finally, run php artisan migrate
.
Support for approving comments
If you are updating an already existing database table comments
and want support for approving comments (new installations get this by default), then create a new migration with php artisan make:migration add_approved_column_to_comments_table
and paste this code inside:
Finally, run php artisan migrate
.
Support for multiple user models
If you are updating an already existing database table comments
and want support for multiple user models (new installations get this by default), then create a new migration with php artisan make:migration add_commenter_type_column_to_comments_table
and paste this code inside:
Then, add doctrine/dbal
dependency with:
Finally, run php artisan migrate
.
Support for non-integer IDs
If you are updating an already existing database table comments
and want support for non-integer IDs (new installations get this by default), then create a new migration with php artisan make:migration allow_commentable_id_to_be_string
and paste this code inside:
Then, add doctrine/dbal
dependency with:
Finally, run php artisan migrate
.
All versions of comments with dependencies
illuminate/support Version ^5.6|^6.0
illuminate/database Version ^5.6|^6.0
illuminate/routing Version ^5.6|^6.0
illuminate/queue Version ^5.6|^6.0
illuminate/http Version ^5.6|^6.0
erusev/parsedown Version ^1.7
spatie/laravel-honeypot Version ^1.3
illuminate/pagination Version ^5.6|^6.0