laravel / 10 / api / 10.x / illuminate / support / traits / conditionable.html

Conditionable

trait Conditionable (View source)

Methods

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

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

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

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

Details

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

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

Parameters

$value
callable $callback
callable $default

Return Value

$this|TWhenReturnType

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

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

Parameters

$value
callable $callback
callable $default

Return Value

$this|TUnlessReturnType

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Support/Traits/Conditionable.html