InteractsWithData
trait InteractsWithData
Methods
Retrieve all data from the instance.
Retrieve data from the instance.
Determine if the data contains a given key.
Determine if the data contains a given key.
Determine if the instance contains any of the given keys.
Apply the callback if the instance contains the given key.
Determine if the instance contains a non-empty value for the given key.
Determine if the instance contains an empty value for the given key.
Determine if the instance contains a non-empty value for any of the given keys.
Apply the callback if the instance contains a non-empty value for the given key.
Apply the callback if the instance contains a valid enum value for the given key.
Determine if the instance is missing a given key.
Apply the callback if the instance is missing the given key.
Determine if the given key is an empty string for "filled".
Retrieve data from the instance as a Stringable instance.
Retrieve data from the instance as a Stringable instance.
Retrieve data as a boolean value.
Retrieve data as an integer value.
Retrieve data as a float value.
Retrieve data clamped between min and max values.
Retrieve data from the instance as a Carbon instance.
Retrieve data from the instance as a CarbonInterval instance.
Retrieve data from the instance as an enum.
Retrieve data from the instance as an array of enums.
Retrieve data from the instance as an array.
Retrieve data from the instance as a collection.
Get a subset containing the provided keys with values from the instance data.
Get all of the data except for a specified array of items.
Details
at line 29
abstract array
all(mixed $keys = null)
Retrieve all data from the instance.
at line 34
abstract protected mixed
data(string|null $key = null, mixed $default = null)
Retrieve data from the instance.
at line 39
bool
exists(array|string $key)
Determine if the data contains a given key.
at line 47
bool
has(array|string $key)
Determine if the data contains a given key.
at line 66
bool
hasAny(array|string $keys)
Determine if the instance contains any of the given keys.
at line 85
mixed
whenHas(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains the given key.
at line 101
bool
filled(array|string $key)
Determine if the instance contains a non-empty value for the given key.
at line 118
bool
isNotFilled(array|string $key)
Determine if the instance contains an empty value for the given key.
at line 135
bool
anyFilled(array|string $keys)
Determine if the instance contains a non-empty value for any of the given keys.
at line 159
mixed
whenFilled(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a non-empty value for the given key.
at line 184
mixed
whenEnum(string $key, string $enumClass, callable $callback, callable|null $default = null)
Apply the callback if the instance contains a valid enum value for the given key.
at line 200
bool
missing(array|string $key)
Determine if the instance is missing a given key.
at line 217
mixed
whenMissing(string $key, callable $callback, callable|null $default = null)
Apply the callback if the instance is missing the given key.
at line 233
protected bool
isEmptyString(string $key)
Determine if the given key is an empty string for "filled".
at line 245
Stringable
str(string $key, mixed $default = null)
Retrieve data from the instance as a Stringable instance.
at line 253
Stringable
string(string $key, mixed $default = null)
Retrieve data from the instance as a Stringable instance.
at line 263
bool
boolean(string|null $key = null, bool $default = false)
Retrieve data as a boolean value.
Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
at line 271
int
integer(string $key, int $default = 0)
Retrieve data as an integer value.
at line 279
float
float(string $key, float $default = 0.0)
Retrieve data as a float value.
at line 287
int|float
clamp(string $key, int|float $min, int|float $max, int|float $default = 0)
Retrieve data clamped between min and max values.
at line 305
CarbonInterface|null
date(string $key, string|null $format = null, UnitEnum|string|null $tz = null)
Retrieve data from the instance as a Carbon instance.
at line 323
CarbonInterval|null
interval(string $key, Unit|string|null $unit = null)
Retrieve data from the instance as a CarbonInterval instance.
at line 350
mixed
enum(string $key, string $enumClass, mixed $default = null)
Retrieve data from the instance as an enum.
at line 367
array
enums(string $key, string $enumClass)
Retrieve data from the instance as an array of enums.
at line 382
array
array(array|string|null $key = null)
Retrieve data from the instance as an array.
at line 390
Collection
collect(array|string|null $key = null)
Retrieve data from the instance as a collection.
at line 398
array
only(mixed $keys)
Get a subset containing the provided keys with values from the instance data.
at line 420
array
except(mixed $keys)
Get all of the data except for a specified array of items.