trait Conditionable (View source)

Methods

$this|TWhenReturnType
when(TWhenParameter|TWhenParameter|null $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

$this|TUnlessReturnType
unless(TUnlessParameter|TUnlessParameter|null $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Details

$this|TWhenReturnType when(TWhenParameter|TWhenParameter|null $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

TWhenParameter|TWhenParameter|null $value
callable|null $callback
callable|null $default

Return Value

$this|TWhenReturnType

$this|TUnlessReturnType unless(TUnlessParameter|TUnlessParameter|null $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

TUnlessParameter|TUnlessParameter|null $value
callable|null $callback
callable|null $default

Return Value

$this|TUnlessReturnType

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.