Require this package, with Composer, in the root directory of your project.
$ composer require faustbrian/laravel-reviewable
And then include the service provider within app/config/app.php
.
'providers' => [
BrianFaust\Reviewable\ReviewableServiceProvider::class
];
To get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="BrianFaust\Reviewable\ReviewableServiceProvider" && php artisan migrate
<?php
namespace App;
use BrianFaust\Reviewable\HasReviewsTrait;
use BrianFaust\Reviewable\Interfaces\HasReviews;
use Illuminate\Database\Eloquent\Model;
class Post extends Model implements HasReviews
{
use HasReviewsTrait;
}
$user = User::first();
$post = Post::first();
$review = $post->review([
'title' => 'Some title',
'body' => 'Some body',
'rating' => 5,
], $user);
dd($review);
$review = $post->updateReview(1, [
'title' => 'new title',
'body' => 'new body',
'rating' => 3,
]);
$post->deleteReview(1);
If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at [email protected]. All security vulnerabilities will be promptly addressed.
The The MIT License (MIT). Please check the LICENSE file for more details.