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 response and photo cleanup hooks, the factories and the Pest expectations — resolves the configured class.
- The migrations follow the configured model: create_reviews_table creates its table (parent_id referencing that same table) and leaves one that already exists alone, and the review_votes foreign key and the cascade migration target it too — so a custom model on its own table works.
- Already own an unrelated reviews table? Point model at a model on another table before migrating — otherwise create_reviews_table skips the existing table and the package writes into it.
- 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.