2017 © Pedro PelĆ”ez
 

library laravel-comment

Just another comment system for laravel projects.

image

actuallymab/laravel-comment

Just another comment system for laravel projects.

  • Friday, March 16, 2018
  • by ActuallyMAB
  • Repository
  • 9 Watchers
  • 106 Stars
  • 18,246 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 17 Forks
  • 11 Open issues
  • 10 Versions
  • 18 % Grown

The README.md

Laravel Comment

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

Just another comment system for your awesome Laravel project., (*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

For >5.5 you can use ^1.0.0 version., (*3)

Install

Via Composer, (*4)

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


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 configurations and migrations, then migrate comments table., (*6)

``` bash $ php artisan vendor:publish $ php artisan migrate, (*7)


Add `CanComment` trait to your User model. ``` php use Actuallymab\LaravelComment\CanComment; class User extends Model { use CanComment; // ... }

Add Commentable interface and HasComments trait to your commentable model(s)., (*8)

``` php use Actuallymab\LaravelComment\Contracts\Commentable; use Actuallymab\LaravelComment\HasComments;, (*9)

class Product extends Model implements Commentable { use HasComments;, (*10)

// ...   

}, (*11)


If you want to have your own Comment Model create a new one and extend my Comment model. ``` php use Actuallymab\LaravelComment\Models\Comment as LaravelComment; class Comment extends LaravelComment { // ... }

and dont forget to update the model name in the config/comment.php file., (*12)

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

1- If you want to users can rate your commentable models;, (*14)

``` php class Product extends Model implements Commentable { use HasComments;, (*15)

public function canBeRated(): bool
{
    return true; // default false
}

//...

}, (*16)


2- If you want to approve comments for your commentable models; ``` php class Product extends Model implements Commentable { use HasComments; public function mustBeApproved(): bool { return true; // default false } // ... }

3- Sometimes you don't want to approve comments for all users;, (*17)

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

protected $fillable = [
    'isAdmin',
    // ..
];

public function canCommentWithoutApprove(): bool
{
    return $this->isAdmin;
}

// ..

}, (*19)


## Usage ``` php $user = App\User::first(); $product = App\Product::first(); // $user->comment(Commentable $model, $comment = '', $rate = 0); $user->comment($product, 'Lorem ipsum ..', 3); // approve it -- if the user model `canCommentWithoutApprove()` or you don't use `mustBeApproved()`, it is not necessary $product->comments[0]->approve(); // get avg rating -- it calculates approved average rate. $product->averageRate(); // get total comments count -- it calculates approved comments count. $product->totalCommentsCount();

Tip: You might want to look at the tests/CommentTest.php file to check all potential usages., (*20)

Change log

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

Testing

bash $ composer test, (*22)

Contributing

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

Security

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

Credits

License

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

The Versions

16/03 2018

dev-feature/laravel-56

dev-feature/laravel-56 https://github.com/actuallymab/laravel-comment

Just another comment system for laravel projects.

  Sources   Download

MIT

The Requires

 

The Development Requires

actuallymab laravel-comment

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