laravel-settings
Advanced Usage
Team Resolver
On this page
Introduction
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);
Advanced Usage
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 overresolveUsing().
Methods
resolve
public function resolve(): string|int|null
resolveUsing
public function resolveUsing(?Closure $callback): static
setDefaultTeam
public function setDefaultTeam(mixed $team): static
withTeam
public function withTeam(mixed $team, Closure $callback): mixed
setTeam
public function setTeam(mixed $team): static