2017 © Pedro Peláez
 

library commentable

A basic starting point for a flexible commentable system in Laravel

image

tavaresevora/commentable

A basic starting point for a flexible commentable system in Laravel

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

The README.md

Commentable

Installation

Add commentable to your composer.json file to require :, (*1)

    require : {
        ...
        "tavaresevora/commentable": "dev-master"
    }

Update Composer :, (*2)

    composer update

The next required step is to add the service provider to config/app.php : ``` php Tavaresevora\Commentable\CommentableServiceProvider::class,, (*3)


Migrate comments table

php artisan vendor:publish --tag=comment-migrations php artisan migrate, (*4)


### Usage ### Add commentable in model ``` php <?php namespace App; use Illuminate\Database\Eloquent\Model; use Tavaresevora\Commentable\Commentable; class Post extends Model { use Commentable; ... }

Add new comment ``` php <?php, (*5)

$post = App\Post::first();
$user = Auth::user();
$post->addComment('Superbe article !', $user);

//addComment($body, Model $author, $validate = NULL);

update a comment ``` php <?php $post = App\Post::first(); $comment = $post->comments->first(); $user = Auth::user(); $post->updateComment($comment, $body) // If you want change the author $newUser = User::find(2); $post->updateComment($comment, $body, $newUser) //updateComment(Comment $comment, $body, Model $author = NULL)

delete a comment ``` php <?php, (*6)

$post = App\Post::first();
$comment = $post->comments->first();
$post->deleteComment($comment)

//deleteComment(Comment $comment)

get author of comment ``` php <?php @foreach($post->comments as $comment) <p> {{ $comment->body }} - <span>{{ $comment->author->name }}</span> </p> @endforeach

The Versions

07/11 2017

dev-master

9999999-dev https://github.com/TavaresEvora/commentable

A basic starting point for a flexible commentable system in Laravel

  Sources   Download

MIT

The Requires

 

07/11 2017

v0.5

0.5.0.0 https://github.com/TavaresEvora/commentable

A basic starting point for a flexible commentable system in Laravel

  Sources   Download

MIT