---
title: "Custom models & macros — Reviews for Laravel | Roundly"
description: "Swap in your own Review or ReviewVote model, register custom facade verbs as macros, and control the facade alias."
url: https://roundly-consulting.com/open-source/docs/reviews-for-laravel/extending
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Reviews for Laravel](https://roundly-consulting.com/open-source/docs/reviews-for-laravel.md)

# 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:

```php
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:

```php
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 crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/reviews-for-laravel.md)
