NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Options for Laravel

Fluent API & bulk operations

Options::option() returns a context for a single global option; Options::for($owner) scopes everything that follows to an owner:

Options::option(ThemeOption::class)->set('dark');
Options::option(ThemeOption::class)->get();       // or ->value()
Options::option(ThemeOption::class)->has();
Options::option(ThemeOption::class)->forget();    // or ->reset()
Options::option(ThemeOption::class)->default();
Options::option(ThemeOption::class)->remember(fn () => 'dark');
Options::option(ThemeOption::class)->key();       // 'theme'
Options::option(ThemeOption::class)->readable();  // 'Theme'

// Owner-scoped
Options::for($user)->option(ThemeOption::class)->set('light');
Options::for($user)->get(ThemeOption::class);
Options::for($user)->set(ThemeOption::class, 'light');

Options::for($owner) returns a PendingOptions builder with get(), set(), has(), forget(), reset(), remember(), many(), setMany() and all(), plus option() and key() to drop down to a single option. Options::for(null) is the global scope.

Bulk reads and writes

$values = Options::many([ThemeOption::class, LocaleOption::class]);
// [ThemeOption::class => 'dark', LocaleOption::class => 'en'] — keyed by what you passed

Options::setMany([ThemeOption::class => 'dark', LocaleOption::class => 'en']);

Options::for($user)->many(['theme', 'locale']);     // registered keys work too
Options::for($user)->setMany(['theme' => 'light']);

// Everything stored for a scope (raw key => value), in one query
$all = Options::all();               // global
$all = Options::for($user)->all();   // one owner
  • many() returns an array keyed by the identifiers you passed — class-strings or registered keys.
  • setMany() is all or nothing: every value is authorized and validated before the first write, and the writes share one database transaction. Casts, events and observers then apply as for set().
  • all() is different: one query, raw stored strings keyed by option key. No casts, no defaults for unset options, and encrypted values stay ciphertext. With access control on, it leaves out what the current user may not read.

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

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