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

Conditionable

trait Conditionable (View source)

Methods

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

Apply the callback if the given "value" is truthy.

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

Apply the callback if the given "value" is falsy.

Details

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

Apply the callback if the given "value" is truthy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

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

Apply the callback if the given "value" is falsy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

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