naoray / laravel-reviewable
Adds a reviewable feature to your app.
Installs: 397
Dependents: 0
Suggesters: 0
Security: 0
Stars: 56
Watchers: 4
Forks: 7
Open Issues: 1
Type:package
Requires
- illuminate/support: ~5.7.0|~5.8.0
Requires (Dev)
- orchestra/testbench: ^3.8
README
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.