Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

a2design-inc/Laravel-Reviewable

 
 

Repository files navigation

Laravel Reviewable

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 [email protected]. All security vulnerabilities will be promptly addressed.

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%