NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Shops for Laravel

Reviews & ratings

Products are reviewable via reviews-for-laravel, with star ratings, optional text, moderation and rating aggregates:

$product->addReview($user)
    ->rating(5)
    ->title('Great')
    ->content('Love it')
    ->approved()
    ->create();

$product->reviews();              // MorphMany<Review>
$product->approvedReviews();      // MorphMany<Review>
$product->reviewsCount();         // int
$product->approvedReviewsCount(); // int
$product->averageRating();        // ?float — approved reviews only
$product->ratingDistribution();   // [5 => 12, 4 => 3, ...]
$product->ratingSummary();        // RatingSummary {average, count, distribution}

Verified purchase

$product->review($user) begins a review pre-flagged as a verified purchase by the bound VerifiedPurchaseResolver, then returns the reviews package’s fluent builder. $product->addReview($user) is the un-flagged builder:

// Pre-flags the review as a verified purchase via the bound resolver:
$product->review($user)
    ->rating(5)
    ->title('Excellent')
    ->content('Exactly as described.')
    ->create();   // Review — verified set automatically

The default NullVerifiedPurchaseResolver never verifies. DatabaseVerifiedPurchaseResolver verifies an author with an order that is both paid and fulfilled and contains the product — matched through the order’s customer, so orders need a linked customer:

// config/shops.php
'reviews' => [
    'verified_purchase_resolver' => \RoundlyConsulting\Shops\Reviews\DatabaseVerifiedPurchaseResolver::class,
],

Or implement the contract for your own purchase lookup:

use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Shops\Products\Product;
use RoundlyConsulting\Shops\Reviews\Contracts\VerifiedPurchaseResolver;

final class CrmVerifiedPurchaseResolver implements VerifiedPurchaseResolver
{
    public function verified(Model $author, Product $product): bool
    {
        // your own purchase lookup, e.g. against an external order system
        return false;
    }
}

The review builder also takes photos (withPhoto(), withPhotos(), withPhotoFromUrl(), withPhotoFromDisk(), withDraftPhoto()) — see the reviews-for-laravel docs.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.