2017 © Pedro PelĆ”ez
 

library laravel-comment

Just another comment system for laravel projects.

image

ufutx/laravel-comment

Just another comment system for laravel projects.

  • Tuesday, November 28, 2017
  • by glore
  • Repository
  • 1 Watchers
  • 6 Stars
  • 168 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 16 Versions
  • 8 % Grown

The README.md

Laravel Comment (forked from actuallymab/laravel-comment)

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

**Just another comment system for laravel projects., (*2)

Version Compatibility

Laravel Laravel Comment
5.4.x 1.1.x
5.2.x 0.3.x

Install

Via Composer, (*3)

``` bash $ composer require ufutx/laravel-comment, (*4)


Add service provider to your app.php file ``` php \Ufutx\LaravelComment\LaravelCommentServiceProvider::class

Publish & Migrate comments table. ``` bash $ php artisan vendor:publish $ php artisan migrate, (*5)


Add `CanComment` trait to your User model. ``` php use Ufutx\LaravelComment\CanComment;

Add Commentable trait to your commentable model(s). ``` php use Ufutx\LaravelComment\Commentable;, (*6)


If you want to have your own Comment Model create a new one and extend my Comment model. ``` php class Comment extends Ufutx\LaravelComment\Comment { ... }

Comment package comes with several modes., (*7)

1- If you want to Users can rate your model(s) with comment set canBeRated to true in your Commentable model. ``` php class Product extends Model { use Commentable;, (*8)

protected $canBeRated = true;, (*9)

... }, (*10)


2- If you want to approve comments for your commentable models, you must set `mustBeApproved` to true in your `Commentable` model. ``` php class Product extends Model { use Commentable; protected $mustBeApproved = true; ... }

3- You don't want to approve comments for all users (think this as you really want to approve your own comments?). So add your User model an isAdmin method and return it true if user is admin., (*11)

``` php class User extends Model { use CanComment;, (*12)

protected $fillable = [ 'isAdmin', .... ];, (*13)

public function isAdmin() { return $this->isAdmin; }, (*14)

... }, (*15)


## Usage ``` php $user = App\User::find(1); $product = App\Product::find(1); // $user->comment(Commentable $model, $comment = '', $rate = 0, $pic = null); $user->comment($product, 'Lorem ipsum ..', 3, 'http://images.ufutx.com/201702/09/49fe31fdf2d4f74709f2cb00e1a9c49a.jpeg@1e_1c_2o_1l_200h_200w_90q.src'); // approve it -- if you are admin or you don't use mustBeApproved option, it is not necessary $product->comments[0]->approve(); //comment user model record $product->comments[0]->user // get avg rating -- it calculates approved average rate. $product->averageRate(); // get total comment count -- it calculates approved comments count. $product->totalCommentCount();

Change log

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

Testing

bash $ composer test, (*17)

Contributing

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

Security

If you discover any security related issues, please email mehmet.aydin.bahadir@gmail.com or zglore instead of using the issue tracker., (*19)

Credits

License

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

The Versions

28/11 2017
13/05 2017
12/05 2017
10/05 2017
10/05 2017
03/03 2017
23/02 2017
23/02 2017