ConditionallyLoadsAttributes
trait ConditionallyLoadsAttributes
Properties
| static protected array<class-string, bool> | $cachedPreserveKeysAttributes | The cached preserve keys attribute values. |
Methods
Filter the given data, removing any optional values.
Merge the given data in at the given index.
Remove the missing values from the filtered data.
Retrieve a value if the given "condition" is truthy.
Retrieve a value if the given "condition" is falsy.
Merge a value into the array.
Merge a value if the given condition is truthy.
Merge a value unless the given condition is truthy.
Merge the given attributes.
Retrieve an attribute if it exists on the resource.
Retrieve a model attribute if it is null.
Retrieve a model attribute if it is not null.
Retrieve an accessor when it has been appended.
Retrieve a relationship if it has been loaded.
Retrieve a relationship count if it exists.
Retrieve a relationship aggregated value if it exists.
Retrieve a relationship existence check if it exists.
Execute a callback if the given pivot table has been loaded.
Execute a callback if the given pivot table with a custom accessor has been loaded.
Determine if the resource has the specified pivot table loaded.
Determine if the resource has the specified pivot table loaded with a custom accessor.
Transform the given value if it is present.
Details
at line 24
protected array
filter(array $data)
Filter the given data, removing any optional values.
at line 57
protected array
mergeData(array $data, int $index, array $merge, bool $numericKeys)
Merge the given data in at the given index.
at line 74
protected array
removeMissingValues(array $data)
Remove the missing values from the filtered data.
at line 111
protected mixed
when(bool $condition, mixed $value, mixed $default = new MissingValue())
Retrieve a value if the given "condition" is truthy.
at line 125
mixed
unless(bool $condition, mixed $value, mixed $default = new MissingValue())
Retrieve a value if the given "condition" is falsy.
at line 137
protected mixed
merge(mixed $value)
Merge a value into the array.
at line 147
protected mixed
mergeWhen(bool $condition, mixed $value, mixed $default = new MissingValue())
Merge a value if the given condition is truthy.
at line 161
protected mixed
mergeUnless(bool $condition, mixed $value, mixed $default = new MissingValue())
Merge a value unless the given condition is truthy.
at line 171
protected MergeValue
attributes(array $attributes)
Merge the given attributes.
at line 183
mixed
whenHas(string $attribute, mixed $value = null, mixed $default = new MissingValue())
Retrieve an attribute if it exists on the resource.
at line 199
protected mixed
whenNull(mixed $value, mixed $default = new MissingValue())
Retrieve a model attribute if it is null.
at line 211
protected mixed
whenNotNull(mixed $value, mixed $default = new MissingValue())
Retrieve a model attribute if it is not null.
at line 223
protected mixed
whenAppended(string $attribute, mixed $value = null, mixed $default = new MissingValue())
Retrieve an accessor when it has been appended.
at line 237
protected mixed
whenLoaded(string $relationship, mixed $value = null, mixed $default = new MissingValue())
Retrieve a relationship if it has been loaded.
at line 265
mixed
whenCounted(string $relationship, mixed $value = null, mixed $default = new MissingValue())
Retrieve a relationship count if it exists.
at line 293
mixed
whenAggregated(string $relationship, string $column, string $aggregate, mixed $value = null, mixed $default = new MissingValue())
Retrieve a relationship aggregated value if it exists.
at line 321
mixed
whenExistsLoaded(string $relationship, mixed $value = null, mixed $default = new MissingValue())
Retrieve a relationship existence check if it exists.
at line 345
protected mixed
whenPivotLoaded(string $table, mixed $value, mixed $default = new MissingValue())
Execute a callback if the given pivot table has been loaded.
at line 355
protected mixed
whenPivotLoadedAs(string $accessor, string $table, mixed $value, mixed $default = new MissingValue())
Execute a callback if the given pivot table with a custom accessor has been loaded.
at line 367
protected bool
hasPivotLoaded(string $table)
Determine if the resource has the specified pivot table loaded.
at line 375
protected bool
hasPivotLoadedAs(string $accessor, string $table)
Determine if the resource has the specified pivot table loaded with a custom accessor.
at line 385
protected mixed
transform(mixed $value, callable $callback, mixed $default = new MissingValue())
Transform the given value if it is present.