a2design/laravel-reviewable

This package is abandoned and no longer maintained. The author suggests using the faustbrian/laravel-reviewable package instead.

Reviewable Polymorphic Eloquent Models for Laravel 5

2.3.1 2016-11-21 10:18 UTC

README

Installation

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

Usage

Setup a Model

<?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;
}

Create a review

$user = User::first();
$post = Post::first();

$review = $post->review([
    'title' => 'Some title',
    'body' => 'Some body',
    'rating' => 5,
], $user);

dd($review);

Update a review

$review = $post->updateReview(1, [
    'title' => 'new title',
    'body' => 'new body',
    'rating' => 3,
]);

Delete a review

$post->deleteReview(1);

Security

If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at hello@brianfaust.de. All security vulnerabilities will be promptly addressed.

License

The The MIT License (MIT). Please check the LICENSE file for more details.