Skip to content

Adds a reviewable feature to your laravel app.

License

Notifications You must be signed in to change notification settings

AndreFabris/laravel-reviewable

 
 

Repository files navigation

laravel-reviewable

Software License Travis StyleCI Total Downloads

This package adds a reviewable feature to your app.

Install

Laravel Version 5.7+

composer require naoray/laravel-reviewable

Laravel Version 5.6+

composer require naoray/laravel-reviewable:1.1.*

Laravel Version 5.5

composer require naoray/laravel-reviewable:1.0.*

publish config: php artisan vendor:publish --provider="Naoray\LaravelReviewable\LaravelReviewableServiceProvider"

Usage

First, add the Naoray\LaravelReviewable\Traits\HasReviews trait to your model you want to add reviews to.

use Naoray\LaravelReviewable\Traits\HasReviews;

class Post extends Model
{
    use HasReviews;

    // ...
}

Now you can create a review by:

// from reviewable entity
Post::first()->createReview(5, 'Example review text', $author);

// author is assumed to be logged in and executing this operation
Post::first()->createReview(10);

// with helper
review($post, 5, 'Example Text', $author);

and receive review scores by:

// summarizes all scores
Post::first()->score;

// gives the average of all scores
Post::first()->avg_score;

Using your own Review-Model

If you just want to change the global configuration to use your own Review-Model, just create a new Model and reference it in the reviewable.models.review config.

If you do not want to change the global review Model you can take a look at this issue for an example configuration.

Testing

Run the tests with:

vendor/bin/phpunit

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email krishan.koenig@googlemail.com instead of using the issue tracker.

License

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

About

Adds a reviewable feature to your laravel app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%