wimil/comments

Comments for Laravel.


Keywords
comments, laravel, package, php
License
MIT

Documentation

Comments for Laravel.

Installation

From the command line:

composer require wimil/comments

Publish Config & configure (optional)

Publish the config file (optional):

php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=config

Publish Migrations

You can publish migration to allow you to have more control over your table

php artisan vendor:publish --provider="Wimil\Comments\Provider" --tag=migrations

Run migrations

We need to create the table for comments.

php artisan migrate

Add Commenter trait to your Model

Add the Commenter trait to your User model so that you can retrieve the comments for a user:

use Wimil\Comments\Commenter;

class User extends Authenticatable
{
    use Notifiable, Commenter;
}

Add Commentable trait to models

Add the Commentable trait to the model for which you want to enable comments for:

use Wimil\Comments\Commentable;

class Product extends Model
{
    use Commentable;
}

Usage

$user = App\User::first();
$product = App\Product::first();

// $user->comment(Commentable $model, $comment = '');
$user->comment($product, 'Lorem ipsum ..');