class ConditionalLazy extends Lazy

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected bool|null $defaultIncluded from  Lazy

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 $method, array $parameters)

Dynamically handle calls to the class.

static DefaultLazy
create(Closure $value)

Create a lazy value.

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

Create a conditionally included lazy value.

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

Create a lazy value for a loaded model relation.

from  Lazy
static InertiaLazy
inertia(Closure $value)

Create an Inertia lazy prop.

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

Create an Inertia deferred prop.

from  Lazy
static ClosureLazy
closure(Closure $closure)

Lazily expose a closure as the resolved value.

from  Lazy
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.

from  Lazy
bool
isDefaultIncluded()

Determine if this value is included by default.

from  Lazy
bool|null
shouldBeIncluded()

Determine if the value's own condition includes it.

bool
resolvesToData()

Determine if resolving this lazy value produces data.

from  Lazy
mixed
__get(string $name)

Forward property access to the resolved value.

from  Lazy
__construct(Closure $condition, Closure $value)

No description

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

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Lazy at line 28
static DefaultLazy create(Closure $value)

Create a lazy value.

Parameters

Closure $value

Return Value

DefaultLazy

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

Create a conditionally included lazy value.

Parameters

Closure $condition
Closure $value

Return Value

ConditionalLazy

in Lazy 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

in Lazy at line 52
static InertiaLazy inertia(Closure $value)

Create an Inertia lazy prop.

Parameters

Closure $value

Return Value

InertiaLazy

in Lazy 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

in Lazy at line 71
static ClosureLazy closure(Closure $closure)

Lazily expose a closure as the resolved value.

Parameters

Closure $closure

Return Value

ClosureLazy

at line 22
mixed resolve()

Resolve the lazy value.

Return Value

mixed

at line 38
array __serialize()

Get the serializable lazy state.

Return Value

array

at line 50
void __unserialize(array $data)

Restore serialized lazy state.

Parameters

array $data

Return Value

void

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

Include this value without an explicit partial selection.

Parameters

bool $defaultIncluded

Return Value

Lazy

in Lazy at line 104
bool isDefaultIncluded()

Determine if this value is included by default.

Return Value

bool

at line 30
bool|null shouldBeIncluded()

Determine if the value's own condition includes it.

Return Value

bool|null

in Lazy at line 120
bool resolvesToData()

Determine if resolving this lazy value produces data.

Return Value

bool

in Lazy at line 128
mixed __get(string $name)

Forward property access to the resolved value.

Parameters

string $name

Return Value

mixed

at line 13
protected __construct(Closure $condition, Closure $value)

No description

Parameters

Closure $condition
Closure $value