2017 © Pedro Peláez
 

library laravel-commentable

Forked from DraperStudio - Commentable Polymorphic Eloquent Models for for Laravel 5

image

christianvizarra/laravel-commentable

Forked from DraperStudio - Commentable Polymorphic Eloquent Models for for Laravel 5

  • Wednesday, October 19, 2016
  • by christianvizarra
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 25 % Grown

The README.md

Laravel Commentable

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Install

Via Composer, (*2)

``` bash $ composer require christianvizarra/laravel-commentable, (*3)


And then include the service provider within `app/config/app.php`. ``` php 'providers' => [ DraperStudio\Commentable\ServiceProvider::class ];

At last you need to publish and run the migration., (*4)

php artisan vendor:publish --provider="DraperStudio\Commentable\ServiceProvider" && php artisan migrate

Usage

Setup a Model

``` php <?php, (*5)

/* * This file is part of Laravel :package_name. * * (c) DraperStudio hello@draperstudio.tech * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */, (*6)

namespace App;, (*7)

use DraperStudio\Commentable\Contracts\Commentable; use DraperStudio\Commentable\Traits\Commentable as CommentableTrait; use Illuminate\Database\Eloquent\Model;, (*8)

class Post extends Model implements Commentable { use CommentableTrait; }, (*9)


### Create a comment ``` php $user = User::first(); $post = Post::first(); $comment = $post->comment([ 'title' => 'Some title', 'body' => 'Some body', ], $user); dd($comment);

Create a comment as a child of another comment (e.g. an answer)

``` php $user = User::first(); $post = Post::first();, (*10)

$parent = $post->comments->first();, (*11)

$comment = $post->comment([ 'title' => 'Some title', 'body' => 'Some body', ], $user, $parent);, (*12)

dd($comment);, (*13)


### Update a comment ``` php $comment = $post->updateComment(1, [ 'title' => 'new title', 'body' => 'new body', ]);

Delete a comment

``` php $post->deleteComment(1);, (*14)


### Count comments an entity has ``` php $post = Post::first(); dd($post->getCommentCount());

Change log

Please see CHANGELOG for more information what has changed recently., (*15)

Testing

bash $ composer test, (*16)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*17)

Security

If you discover any security related issues, please email hello@draperstudio.tech instead of using the issue tracker., (*18)

Credits

License

The MIT License (MIT). Please see License File for more information., (*19)

commentable

forked of draperstudio/laravel-commentable, (*20)

The Versions