JSON resource
ReviewResource (and ReviewCollection) expose a sensible public shape for API and mobile clients:
use RoundlyConsulting\Reviews\Http\Resources\ReviewResource;
return ReviewResource::collection($product->approvedReviews()->with('responses')->get());| Field | Value |
|---|---|
id / parent_id | Review key; parent key for owner responses. |
rating / status / verified | Score (or null), status string, verified flag. |
title / content | The review text. |
helpful_count / unhelpful_count / helpful_score | Vote tallies and their difference. |
author / reviewable | Each as a { type, id } pair. |
responses | Nested ReviewResource items — only when the relation is loaded. |
photos | A list of { id, url, srcset }, signed when photos are private. |
created_at / updated_at / approved_at | ISO 8601 strings. |
meta is deliberately not exposed, so internal notes and rejection reasons stay private. Photo URLs follow the photo visibility — signed for private photos, never public.
Paginated collections
use RoundlyConsulting\Reviews\Http\Resources\ReviewCollection;
return new ReviewCollection(
$product->approvedReviews()->latestFirst()->paginate(10),
);Customising
Publish editable copies — App\Http\Resources\Reviews\ReviewResource and ReviewCollection in app/Http/Resources/Reviews, app-namespaced classes you own that start out rendering exactly what the package’s resource does:
# Translations → lang/vendor/reviews
php artisan vendor:publish --tag="reviews-translations"
# JSON resources → app/Http/Resources/Reviews
php artisan vendor:publish --tag="reviews-resources"Edit them, and use them in your controllers instead of the package classes:
use App\Http\Resources\Reviews\ReviewResource;
return ReviewResource::collection($product->approvedReviews()->with('responses')->get());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 cryptoBy 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.