---
title: "Preparing your models — Reviews for Laravel | Roundly"
description: "Add HasReviews to subjects, CanReview to authors and CanVoteOnReviews to voters — any model can play any role."
url: https://roundly-consulting.com/open-source/docs/reviews-for-laravel/preparing-models
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)

# Preparing your models

Mark a subject as reviewable and an author as a reviewer with one trait each:

```php
use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Reviews\Concerns\CanReview;
use RoundlyConsulting\Reviews\Concerns\CanVoteOnReviews;
use RoundlyConsulting\Reviews\Concerns\HasReviews;

class Restaurant extends Model
{
    use HasReviews;          // the reviewable subject
}

class User extends Model
{
    use CanReview;           // writes reviews
    use CanVoteOnReviews;    // votes reviews helpful / unhelpful
}
```

- HasReviews — for subjects: the reviews, topLevelReviews and approvedReviews relations, live aggregates (averageRating(), ratingSummary() and more) and addReview().
- CanReview — for authors: the reviewsAuthored relation, hasReviewed() and reviewFor().
- CanVoteOnReviews — for voters: voteOn(), removeVoteFrom(), hasVotedOn() and votedHelpfulOn().
- MaintainsReviewAggregates — optional, alongside HasReviews: keeps cached reviews\_count / reviews\_avg columns in sync.

## Anything can review anything

The traits are conveniences — the facade accepts any Eloquent model as author or subject. A model can hold both roles, which makes two-way feedback trivial:

```php
class Guest extends Model
{
    use CanReview;
    use HasReviews;
}

class Host extends Model
{
    use CanReview;
    use HasReviews;
}

// After a stay, both sides review each other with the same API.
Reviews::for($host)->by($guest)->rating(5)->content('Spotless flat, great tips')->create();
Reviews::for($guest)->by($host)->rating(5)->content('Ideal guest, left it tidy')->create();
```

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