✈️Usage

Commentable Model

Model that the comment belongs to.

Commenter Model

Model that the user belongs to.

Implement CommentableContract and import Commentable trait in commentable model.

use LakM\Commenter\Concerns\Commentable;
use LakM\Commenter\Contracts\CommentableContract;

class Post extends Model implements CommentableContract
{
    use Commentable;
}

Implement CommenterContract and import Commenter trait in commenter model.

use LakM\Commenter\Concerns\Commenter;
use LakM\Commenter\Contracts\CommenterContract;

class User extends Model implements CommenterContract
{
    use Commenter;
}

Include styles in your layout.

<html>
    <head>
        @commenterStyles
    </head>
</html>

To avoid CSS name conflicts, we recommend adding your styles to the end of the head tag.

Include scripts in your layout

<html>
    <body>
        @commenterScripts
    </body>
</html>

To improve performance we recommend adding script at the end of the body tag.

Then simply include component in your blade file

<x-commenter::index :model="$post" />

or you can use components separately,

<div x-cloak x-data class="space-y-8">
    <livewire:comments.list-view :model="$model" />
    <hr class="text-gray-400" />
    <livewire:comments.create-form :model="$model" />
</div>

Last updated

Was this helpful?