2017 © Pedro Peláez
 

library laravel-commentable

Allows for threaded comments to be added to multiple and different models.

image

ican-agency/laravel-commentable

Allows for threaded comments to be added to multiple and different models.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel Commentable

Allows for threaded comments to be added to multiple and different models within your app for Laravel 5., (*1)

Based on now defunct Lanz/Laravel Commentable., (*2)

This package use Nested Sets pattern with Baum., (*3)

More information about Nested Sets, (*4)

Installation

Edit your project's composer.json file to require ican-agency/laravel-commentable., (*5)

"require": {
  "ican-agency/laravel-commentable": "~1.0"
}

Next, update Composer from the terminal., (*6)

composer update

As with most Laravel packages you'll need to register Commentable service provider. In your config/app.php add 'Ican\Commentable\CommentableServiceProvider' to the end of the $providers array., (*7)

'providers' => [

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Ican\Commentable\CommentableServiceProvider',

],

Getting started

After the package is correctly installed, you need to generate migration., (*8)

php artisan commentable:migration

It will generate the <timestamp>_create_comments_table.php migration. You may now run it with the artisan migrate command:, (*9)

php artisan migrate

After the migration, one new table will be present, comments., (*10)

Usage

You need to set on your model that it acts as commentable., (*11)

<?php namespace App;

use Ican\Commentable\Commentable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    use Commentable;

}

Now, your model has access to comments method., (*12)

$post = Post::first();

$comment = new Ican\Commentable\Comment;
$comment->body = 'My first comment!';
$comment->user_id = \Auth::id();

$post->comments()->save($comment);

dd(Post::first()->comments);

For all information about threaded comment, look at the documentation on Baum., (*13)

The Versions

16/12 2016

dev-master

9999999-dev

Allows for threaded comments to be added to multiple and different models.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ICAN

laravel nested set laravel 4 laravel 5 comment threaded commentable

16/12 2016

1.0

1.0.0.0

Allows for threaded comments to be added to multiple and different models.

  Sources   Download

MIT

The Requires

 

The Development Requires

by ICAN

laravel nested set laravel 4 laravel 5 comment threaded commentable