---
title: "Owners & the HasOptions trait — Options for Laravel | Roundly"
description: "Scope values to any Eloquent model — users, teams, tenants — and read them straight off the model with the HasOptions trait."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel/owner-scopes
language: en
---

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

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

# Owners & the HasOptions trait

Any Eloquent model can own option values. Pass it as the owner argument, or start with Options::for():

```php
use RoundlyConsulting\Options\Facades\Options;

Options::set(LocaleOption::class, 'sk', $team);
Options::get(LocaleOption::class, $team);   // 'sk'
Options::get(LocaleOption::class);          // the global value — untouched

Options::for($tenant)->set(ThemeOption::class, 'dark');
Options::for($tenant)->get(ThemeOption::class); // 'dark'
```

## The HasOptions trait

Add HasOptions to a model to resolve options bound to it:

```php
use RoundlyConsulting\Options\Traits\HasOptions;

final class User extends Authenticatable
{
    use HasOptions;
}

$user->option(ThemeOption::class)->value();    // this user’s value, or the default
$user->option(ThemeOption::class)->set('dark');
$user->option('theme')->value();               // a registered key works too
```

option() returns the option instance scoped to that model, so value(), set(), has(), forget() and remember() all act on the model’s own row. It accepts a class-string or a registered key. The trait is sugar over the same manager — $user->option(ThemeOption::class)->set('dark') is exactly Options::set(ThemeOption::class, 'dark', $user), fake included.

## How scopes stay isolated

Rows are matched on owner\_type — the model’s morph class, so morph-map aliases apply — and owner\_id. Cache entries are fingerprinted the same way, so one user’s value never leaks into another user’s scope or the global one.

## 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/options-for-laravel.md)
