PHP code example of naoray / laravel-reviewable

1. Go to this page and download the library: Download naoray/laravel-reviewable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

naoray / laravel-reviewable example snippets


use Naoray\LaravelReviewable\Traits\HasReviews;

class Post extends Model
{
    use HasReviews;

    // ...
}

// 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);

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

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