Custom models & macros
Point the model (or vote_model) config key at a class that extends the package’s model to add relationships, scopes or accessors:
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use RoundlyConsulting\Reviews\Models\Review as BaseReview;
class Review extends BaseReview
{
public function scopeFeatured(Builder $query): void
{
$query->approved()->verified()->withRatingOf(5);
}
}
// config/reviews.php
'model' => App\Models\Review::class,- Every read and write — actions, relations, aggregates, the aggregate observer, the photo cleanup hook and the Pest expectations — resolves the configured class.
- The review_votes foreign key targets the configured model’s table, so a custom model on its own table works.
- A configured class must be the package model or extend it: anything else — an unrelated Eloquent model included — throws InvalidConfigurationException naming the key, never silently replaced by the packaged one. An unset or blank key resolves the packaged model.
- Scopes come from the HasReviewScopes trait and photos from HasReviewPhotos, so your subclass keeps both.
Custom verbs (macros)
ReviewsManager is Macroable, so you can register your own facade verbs:
use RoundlyConsulting\Reviews\Facades\Reviews;
use RoundlyConsulting\Reviews\Models\Review;
Reviews::macro('flagged', fn () => Review::query()->rejected()->get());
Reviews::flagged();Facade alias
By default the package registers a global Reviews alias. If it collides with a class in your app, set REVIEWS_REGISTER_FACADE_ALIAS=false — the fully qualified RoundlyConsulting\Reviews\Facades\Reviews facade keeps working. Any other string registers the alias under that name instead; a blank value is not set, so the Reviews alias is still registered.
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.