abstract class Lazy

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected bool|null $defaultIncluded

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $name, array $arguments)

Run a registered macro or forward the call to the resolved value.

static DefaultLazy
create(Closure $value)

Create a lazy value.

static ConditionalLazy
when(Closure $condition, Closure $value)

Create a conditionally included lazy value.

static RelationalLazy
whenLoaded(string $relation, Model $model, Closure $value)

Create a lazy value for a loaded model relation.

static InertiaLazy
inertia(Closure $value)

Create an Inertia lazy prop.

static InertiaDeferred
inertiaDeferred(mixed $value, string|null $group = null, bool $rescue = false)

Create an Inertia deferred prop.

static ClosureLazy
closure(Closure $closure)

Lazily expose a closure as the resolved value.

mixed
resolve()

Resolve the lazy value.

array
__serialize()

Get the serializable lazy state.

void
__unserialize(array $data)

Restore serialized lazy state.

defaultIncluded(bool $defaultIncluded = true)

Include this value without an explicit partial selection.

bool
isDefaultIncluded()

Determine if this value is included by default.

bool|null
shouldBeIncluded()

Get an intrinsic inclusion decision when the lazy type owns one.

bool
resolvesToData()

Determine if resolving this lazy value produces data.

mixed
__get(string $name)

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 136
mixed __call(string $name, array $arguments)

Run a registered macro or forward the call to the resolved value.

Parameters

string $name
array $arguments

Return Value

mixed

at line 28
static DefaultLazy create(Closure $value)

Create a lazy value.

Parameters

Closure $value

Return Value

DefaultLazy

at line 36
static ConditionalLazy when(Closure $condition, Closure $value)

Create a conditionally included lazy value.

Parameters

Closure $condition
Closure $value

Return Value

ConditionalLazy

at line 44
static RelationalLazy whenLoaded(string $relation, Model $model, Closure $value)

Create a lazy value for a loaded model relation.

Parameters

string $relation
Model $model
Closure $value

Return Value

RelationalLazy

at line 52
static InertiaLazy inertia(Closure $value)

Create an Inertia lazy prop.

Parameters

Closure $value

Return Value

InertiaLazy

at line 60
static InertiaDeferred inertiaDeferred(mixed $value, string|null $group = null, bool $rescue = false)

Create an Inertia deferred prop.

Parameters

mixed $value
string|null $group
bool $rescue

Return Value

InertiaDeferred

at line 71
static ClosureLazy closure(Closure $closure)

Lazily expose a closure as the resolved value.

Parameters

Closure $closure

Return Value

ClosureLazy

at line 79
abstract mixed resolve()

Resolve the lazy value.

Return Value

mixed

at line 84
abstract array __serialize()

Get the serializable lazy state.

Return Value

array

at line 89
abstract void __unserialize(array $data)

Restore serialized lazy state.

Parameters

array $data

Return Value

void

at line 94
Lazy defaultIncluded(bool $defaultIncluded = true)

Include this value without an explicit partial selection.

Parameters

bool $defaultIncluded

Return Value

Lazy

at line 104
bool isDefaultIncluded()

Determine if this value is included by default.

Return Value

bool

at line 112
bool|null shouldBeIncluded()

Get an intrinsic inclusion decision when the lazy type owns one.

Return Value

bool|null

at line 120
bool resolvesToData()

Determine if resolving this lazy value produces data.

Return Value

bool

at line 128
mixed __get(string $name)

Forward property access to the resolved value.

Parameters

string $name

Return Value

mixed