{"id":13609622,"url":"https://github.com/laravelista/comments","last_synced_at":"2025-04-14T22:13:07.188Z","repository":{"id":37510597,"uuid":"73737370","full_name":"laravelista/comments","owner":"laravelista","description":"Native comments for your Laravel application.","archived":false,"fork":false,"pushed_at":"2024-03-16T14:32:41.000Z","size":1403,"stargazers_count":750,"open_issues_count":23,"forks_count":143,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-14T22:12:54.108Z","etag":null,"topics":["blade","comments","hacktoberfest","laravel","package","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laravelista.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"laravelista"}},"created_at":"2016-11-14T19:02:34.000Z","updated_at":"2025-03-27T20:51:25.000Z","dependencies_parsed_at":"2023-02-16T12:01:23.411Z","dependency_job_id":"cc2b47ef-24db-4201-ae91-6c08b7e66180","html_url":"https://github.com/laravelista/comments","commit_stats":{"total_commits":111,"total_committers":21,"mean_commits":5.285714285714286,"dds":0.4774774774774775,"last_synced_commit":"65e660acf8ea484cbea44807044da5173c13140f"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelista%2Fcomments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelista%2Fcomments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelista%2Fcomments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelista%2Fcomments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laravelista","download_url":"https://codeload.github.com/laravelista/comments/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968917,"owners_count":21191162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blade","comments","hacktoberfest","laravel","package","php"],"created_at":"2024-08-01T19:01:36.606Z","updated_at":"2025-04-14T22:13:07.165Z","avatar_url":"https://github.com/laravelista.png","language":"PHP","readme":"# Comments\n\nComments is a Laravel package. With it you can easily implement native comments for your application.\n\n[![Become a Patron](https://img.shields.io/badge/Become%20a-Patron-f96854.svg?style=for-the-badge)](https://www.patreon.com/laravelista)\n\n\n## Overview\n\nThis package can be used to comment on any model you have in your application.\n\nAll comments are stored in a single table with a polymorphic relation for content and a polymorphic relation for the user who posted the comment.\n\n\n### Features\n\n- View comments\n- Create comments\n- Delete comments\n- Edit comments\n- Reply to comments\n- Authorization rules\n- Support localization\n- Dispatch events\n- Route, Controller, Comment, Migration \u0026 View customizations\n- Support for non-integer IDs\n- Support for multiple User models\n- Solved N+1 query problem\n- Comment approval (opt-in)\n- Guest commenting (opt-in)\n- Pagination (opt-in)\n- Soft deletes (opt-in)\n- Works with custom ID columns\n- Optionally load package migrations [NEW]\n- Configure maximum indentation level [NEW]\n\n\n### Screenshots\n\nHere are a few screenshots.\n\nNo comments \u0026 guest:\n\n![](https://i.imgur.com/9df4Xun.png)\n\nNo comments \u0026 logged in:\n\n![](https://i.imgur.com/ALI6GbR.png)\n\nOne comment:\n\n![](https://i.imgur.com/9wBNiy2.png)\n\nOne comment edit form:\n\n![](https://i.imgur.com/cxDh34O.png)\n\nTwo comments from different users:\n\n![](https://i.imgur.com/2P5u25x.png)\n\n\n### Tutorials \u0026 articles\n\nI 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.\n\n**Screencasts:**\n\n- [Adding comments to your Laravel application](https://www.youtube.com/watch?v=YhA0CSX1HIg) by Andre Madarang.\n\n\n## Installation\n\nFrom the command line:\n\n```bash\ncomposer require laravelista/comments\n```\n\n\n### Run migrations\n\nWe need to create the table for comments.\n\n```bash\nphp artisan migrate\n```\n\n\n### Add Commenter trait to your User model\n\nAdd the `Commenter` trait to your User model so that you can retrieve the comments for a user:\n\n```php\nuse Laravelista\\Comments\\Commenter;\n\nclass User extends Authenticatable\n{\n    use Notifiable, Commenter;\n}\n```\n\n\n### Add Commentable trait to models\n\nAdd the `Commentable` trait to the model for which you want to enable comments for:\n\n```php\nuse Laravelista\\Comments\\Commentable;\n\nclass Product extends Model\n{\n    use Commentable;\n}\n```\n\n\n### Publish Config \u0026 configure (optional)\n\nPublish the config file (optional):\n\n```bash\nphp artisan vendor:publish --provider=\"Laravelista\\Comments\\ServiceProvider\" --tag=config\n```\n\n\n### Publish views (customization)\n\nThe default UI is made for Bootstrap 4, but you can change it however you want.\n\n```bash\nphp artisan vendor:publish --provider=\"Laravelista\\Comments\\ServiceProvider\" --tag=views\n```\n\n\n### Publish Migrations (customization)\n\nYou can publish migration to allow you to have more control over your table\n\n```bash\nphp artisan vendor:publish --provider=\"Laravelista\\Comments\\ServiceProvider\" --tag=migrations\n```\n\n\n### Publish translations (customization)\n\nThe package currently only supports English, but I am open to PRs for other languages.\n\n```bash\nphp artisan vendor:publish --provider=\"Laravelista\\Comments\\ServiceProvider\" --tag=translations\n```\n\n\n## Usage\n\nIn the view where you want to display comments, place this code and modify it:\n\n```\n@comments(['model' =\u003e $book])\n```\n\nIn 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.\n\nIf you open the page containing the view where you have placed the above code, you should see a working comments form.\n\n\n### View only approved comments\n\nTo view only approved comments, use this code:\n\n```\n@comments([\n    'model' =\u003e $book,\n    'approved' =\u003e true\n])\n```\n\n\n### Paginate comments\n\nPagination paginates by top level comments only, meaning that if you specify the number of comments per page to be 1, and that one comment has 100 replies, it will display that one comment and all of its replies.\n\nIt was not possible to do it any other way, because if I paginate by all comments (parent and child) you will end up with blank pages since the comments components loops parent comments first and then uses recursion for replies.\n\nTo use pagination, use this code:\n\n```\n@comments([\n    'model' =\u003e $user,\n    'perPage' =\u003e 2\n])\n```\n\nReplace `2` with any number you want.\n\n### Configure maximum indentation level\n\nBy default the replies go up to level three. After that they are \"mashed\" at that level.\n\n```\n- 0\n    - 1\n        - 2\n            - 3\n```\n\nYou can configure the maximum indentation level like so:\n\n```\n@comments([\n    'model' =\u003e $user,\n    'maxIndentationLevel' =\u003e 1\n])\n```\n\n\n## Events\n\nThis package fires events to let you know when things happen.\n\n- `Laravelista\\Comments\\Events\\CommentCreated`\n- `Laravelista\\Comments\\Events\\CommentUpdated`\n- `Laravelista\\Comments\\Events\\CommentDeleted`\n\n\n## REST API\n\nTo change the controller or the routes, see the config.\n\n```\nRoute::post('comments', '\\Laravelista\\Comments\\CommentController@store')-\u003ename('comments.store');\nRoute::delete('comments/{comment}', '\\Laravelista\\Comments\\CommentController@destroy')-\u003ename('comments.destroy');\nRoute::put('comments/{comment}', '\\Laravelista\\Comments\\CommentController@update')-\u003ename('comments.update');\nRoute::post('comments/{comment}', '\\Laravelista\\Comments\\CommentController@reply')-\u003ename('comments.reply');\n```\n\n\n### POST `/comments`\n\nRequest data:\n\n```\n'commentable_type' =\u003e 'required|string',\n'commentable_id' =\u003e 'required|string|min:1',\n'message' =\u003e 'required|string'\n```\n\n\n### PUT `/comments/{comment}`\n\n- {comment} - Comment ID.\n\nRequest data:\n\n```\n'message' =\u003e 'required|string'\n```\n\n\n### POST `/comments/{comment}`\n\n- {comment} - Comment ID.\n\nRequest data:\n\n```\n'message' =\u003e 'required|string'\n```\n\n\n## Upgrading from older versions (troubleshoot)\n\nBefore creating an issue, read [this](./UPGRADE.md).\n\n\n## Sponsors \u0026 Backers\n\nI would like to extend my thanks to the following sponsors \u0026 backers for funding my open-source journey. If you are interested in becoming a sponsor or backer, please visit the [Backers page](https://mariobasic.com/backers).\n\n\n## Contributing\n\nThank you for considering contributing to Comments! The contribution guide can be found [Here](https://mariobasic.com/contributing).\n\n\n## Code of Conduct\n\nIn order to ensure that the open-source community is welcoming to all, please review and abide by the [Code of Conduct](https://mariobasic.com/code-of-conduct).\n\n\n## License\n\nComments is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","funding_links":["https://patreon.com/laravelista","https://www.patreon.com/laravelista"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravelista%2Fcomments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaravelista%2Fcomments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravelista%2Fcomments/lists"}