1. Go to this page and download the library: Download multek/laravel-review 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/ */
multek / laravel-review example snippets
use Multek\Review\Traits\HasReviews;
class Product extends Model
{
use HasReviews;
}
use Multek\Review\Traits\CanReview;
class User extends Model
{
use CanReview;
}
// Via the reviewable model
$product->addReview([
'rating' => 5,
'title' => 'Amazing!',
'body' => 'Best product ever.',
], $user);
// Via the author model
$user->review($product, [
'rating' => 4,
'body' => 'Pretty good.',
]);
$review->approve();
$review->reject();
$review->addReply('Thank you for your feedback!');
$review->isApproved();
$review->isPending();
$review->isRejected();
// On Review model
Review::approved()->get();
Review::pending()->get();
Review::byAuthor($user)->get();
// On reviewable models
Product::orderByAverageRating('desc')->get();
Product::orderByReviewCount('desc')->get();
Product::hasMinimumRating(4)->get();
Product::hasMinimumReviews(10)->get();
Product::withReviewSummary()->get();