laravel-settings

Advanced Usage

Team Resolver

The TeamResolver class handles resolving the current team to use for an operation. It is registered as a scoped binding (per request) in the container.

For most cases, you should use the Settings Facade instead of interacting with TeamResolver directly:

use Rawilk\Settings\Facades\Settings;

// Scoped team
Settings::defaultTeam($team, function () {
    // all operations here will have the `$team` set as the team_id.
});

// Global team
Settings::defaultTeam($team);

If you need lower-level control, resolve the TeamResolver from the container:

use Rawilk\Settings\Support\TeamResolver;

// Custom resolution callback
app(TeamResolver::class)->resolveUsing(fn () => $teamId);

{note} The setTeam() method on the resolver takes priority over resolveUsing().

public function resolve(): string|int|null
public function resolveUsing(?Closure $callback): static
public function setDefaultTeam(mixed $team): static
public function withTeam(mixed $team, Closure $callback): mixed
public function setTeam(mixed $team): static
Previous
Macros