2017 © Pedro PelĆ”ez
 

library laravel-comment

Just another comment system for laravel projects.

image

iahmad/laravel-comment

Just another comment system for laravel projects.

  • Friday, February 16, 2018
  • by iahmad
  • Repository
  • 1 Watchers
  • 1 Stars
  • 28 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 8 Versions
  • 22 % Grown

The README.md

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.0.x 0.1.x
5.1.x 0.1.x
5.2.x 0.1.x
5.3.x 0.2.x
5.4.x 0.3.x
5.5.x 0.4.x

Install

Via Composer, (*3)

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

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you don't use auto-discovery, or using Laravel version < 5.5 Add service provider to your app.php file

``` php
\Actuallymab\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 Actuallymab\LaravelComment\CanComment;

Add Commentable trait to your commentable model(s). ``` php use Actuallymab\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 Actuallymab\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); $user->comment($product, 'Lorem ipsum ..', 3); // approve it -- if you are admin or you don't use mustBeApproved option, it is not necessary $product->comments[0]->approve(); // 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 instead of using the issue tracker., (*19)

Credits

License

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

The Versions

06/04 2017
31/01 2017
20/10 2016

0.2.1

0.2.1.0 https://github.com/actuallymab/laravel-comment

Just another comment system for laravel projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

actuallymab laravel-comment

18/10 2016

0.2.0

0.2.0.0 https://github.com/actuallymab/laravel-comment

Just another comment system for laravel projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

actuallymab laravel-comment

12/06 2016
12/06 2016