Skip to content

agilepixels/laravel-commentable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Add comments to Eloquent Models

Installation

You can install the package via composer:

composer require agilepixels/laravel-commentable

You must publish the migration with:

php artisan vendor:publish --provider="AgilePixels\Commentable\CommentableServiceProvider" --tag="migrations"

Migrate the comments table:

php artisan migrate

Optionally you can publish the config-file with:

php artisan vendor:publish --provider="AgilePixels\Commentable\CommentableServiceProvider" --tag="config"

Using the traits

To enable the comments for a model, use the AgilePixels\Commentable\Traits\HasComments trait on the model.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use AgilePixels\Commentable\Traits\HasComments;

class Product extends Model
{
    use HasComments;
}

You can use the AgilePixels\Commentable\Traits\AddsComments on the author model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use AgilePixels\Commentable\Traits\AddsComments;

class User extends Model
{
    use AddsComments;
}