Laravel 11's Context: data that belongs to the current request, job or
command, added to every log record and carried into the jobs it
dispatches:
Context.add('tenant_id', tenant.id); // in a middleware
Context.addHidden('api_token', token); // carried, never logged
Context.get<int>('tenant_id'); // later, or inside the queued job
Values must be JSON-encodable, like job data. Outside any scope the data belongs to the isolate.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current → ContextRepository
-
The repository of the current scope (created on first use).
no setter
-
forLogging
→ Map<
String, Object?> -
Visible entries without creating a repository (for log records).
no setter
Static Methods
-
add(
String key, Object? value) → void -
addHidden(
String key, Object? value) → void - Carried into queued jobs like the rest, but never logged.
-
addIf(
String key, Object? value) → void -
Adds
keyonly when it is not set yet. -
addMany(
Map< String, Object?> values) → void -
all(
) → Map< String, Object?> - Every visible entry.
-
allHidden(
) → Map< String, Object?> -
forget(
String key) → void -
forgetHidden(
String key) → void -
get<
T> (String key, [T? fallback]) → T? -
getHidden<
T> (String key, [T? fallback]) → T? -
has(
String key) → bool -
hasHidden(
String key) → bool -
push(
String key, List< Object?> values) → void -
Appends
valuesto the list atkey(Context::push).