Lazy
abstract class Lazy
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected bool|null | $defaultIncluded |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Run a registered macro or forward the call to the resolved value.
Create a lazy value for a loaded model relation.
Create an Inertia deferred prop.
Resolve the lazy value.
Get the serializable lazy state.
Restore serialized lazy state.
Include this value without an explicit partial selection.
Determine if this value is included by default.
Get an intrinsic inclusion decision when the lazy type owns one.
Determine if resolving this lazy value produces data.
Forward property access to the resolved value.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 136
mixed
__call(string $name, array $arguments)
Run a registered macro or forward the call to the resolved value.
at line 28
static DefaultLazy
create(Closure $value)
Create a lazy value.
at line 36
static ConditionalLazy
when(Closure $condition, Closure $value)
Create a conditionally included lazy value.
at line 44
static RelationalLazy
whenLoaded(string $relation, Model $model, Closure $value)
Create a lazy value for a loaded model relation.
at line 52
static InertiaLazy
inertia(Closure $value)
Create an Inertia lazy prop.
at line 60
static InertiaDeferred
inertiaDeferred(mixed $value, string|null $group = null, bool $rescue = false)
Create an Inertia deferred prop.
at line 71
static ClosureLazy
closure(Closure $closure)
Lazily expose a closure as the resolved value.
at line 79
abstract mixed
resolve()
Resolve the lazy value.
at line 84
abstract array
__serialize()
Get the serializable lazy state.
at line 89
abstract void
__unserialize(array $data)
Restore serialized lazy state.
at line 94
Lazy
defaultIncluded(bool $defaultIncluded = true)
Include this value without an explicit partial selection.
at line 104
bool
isDefaultIncluded()
Determine if this value is included by default.
at line 112
bool|null
shouldBeIncluded()
Get an intrinsic inclusion decision when the lazy type owns one.
at line 120
bool
resolvesToData()
Determine if resolving this lazy value produces data.
at line 128
mixed
__get(string $name)
Forward property access to the resolved value.