PHPackages                             tizis/lara-comments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tizis/lara-comments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tizis/lara-comments
===================

Comments system for your Laravel application. Features: can be used to comment on any model, HTML filter customization (HTMLPurifier), API, comment rating, replies, events, auth rules ...

V4.1.0(3y ago)1204.7k17[2 issues](https://github.com/iooe/laravel-comments/issues)[1 PRs](https://github.com/iooe/laravel-comments/pulls)MITPHPPHP ^7.1|^8.0CI failing

Since Nov 17Pushed 10mo ago10 watchersCompare

[ Source](https://github.com/iooe/laravel-comments)[ Packagist](https://packagist.org/packages/tizis/lara-comments)[ RSS](/packages/tizis-lara-comments/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (6)Versions (50)Used By (0)

[README на русском](readme-ru.md)

laraComments
============

[](#laracomments)

This package can be used to comment on any model you have in your application.

### Features

[](#features)

- View comments
- Create comment
- Delete comment
- Edit comment
- Reply to comment
- Authorization rules | with customization
- View customization
- Dispatch events
- Likes | Dislikes | Comment rating
- API for basic function: get, update, delete, create
- HTML filter customization (using HTMLPurifier)

[Upgrade guides → ](#upgrade-guides)
------------------------------------

[](#upgrade-guides--)

- [From 2.x.x to 3.0](#from-2xx-to-30)

Requirements
------------

[](#requirements)

- php 7.1 +
- laravel 5.6 +
- `Your application should contain auth module.`
    - Laravel 6.x:
    - Laravel 5.6:

Installation
------------

[](#installation)

```
composer require tizis/lara-comments
```

### 1. Run migrations

[](#1-run-migrations)

We need to create the table for comments.

```
 php artisan migrate
```

### 2. Add Commenter trait to your User model

[](#2-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:

```
use tizis\laraComments\Traits\Commenter;

class User extends Authenticatable {
	use ..., Commenter;
```

### 3. Create Comment model

[](#3-create-comment-model)

```

use tizis\laraComments\Entity\Comment as laraComment;

class Comment extends laraComment
{

}
```

### 4. Add `Commentable` trait and the `ICommentable` interface to models

[](#4-add-commentable-trait-and-the-icommentable-interface-to-models)

Add the `Commentable` trait and the `ICommentable` interface to the model for which you want to enable comments for:

```
use tizis\laraComments\Contracts\ICommentable;
use tizis\laraComments\Traits\Commentable;

class Post extends Model implements ICommentable {
   use Commentable;
```

### 5. Custom comment policy (optional)

[](#5-custom-comment-policy-optional)

If you need, you can overwrite default comment policy class:

```
