trait ConditionallyLoadsAttributes (View source)
| array | filter(array $data)
Filter the given data, removing any optional values. | |
| array | mergeData(array $data, int $index, array $merge, bool $numericKeys)
Merge the given data in at the given index. | |
| array | removeMissingValues(array $data)
Remove the missing values from the filtered data. | |
| MissingValue|mixed | when(bool $condition, mixed $value, mixed $default = null)
Retrieve a value if the given "condition" is truthy. | |
| MissingValue|mixed | unless(bool $condition, mixed $value, mixed $default = null)
Retrieve a value if the given "condition" is falsy. | |
| MergeValue|mixed | merge(mixed $value)
Merge a value into the array. | |
| MergeValue|mixed | mergeWhen(bool $condition, mixed $value, mixed $default = null)
Merge a value if the given condition is truthy. | |
| MergeValue|mixed | mergeUnless(bool $condition, mixed $value, mixed $default = null)
Merge a value unless the given condition is truthy. | |
| MergeValue | attributes(array $attributes)
Merge the given attributes. | |
| MissingValue|mixed | whenHas(string $attribute, mixed $value = null, mixed $default = null)
Retrieve an attribute if it exists on the resource. | |
| MissingValue|mixed | whenNull(mixed $value, mixed $default = null)
Retrieve a model attribute if it is null. | |
| MissingValue|mixed | whenNotNull(mixed $value, mixed $default = null)
Retrieve a model attribute if it is not null. | |
| MissingValue|mixed | whenAppended(string $attribute, mixed $value = null, mixed $default = null)
Retrieve an accessor when it has been appended. | |
| MissingValue|mixed | whenLoaded(string $relationship, mixed $value = null, mixed $default = null)
Retrieve a relationship if it has been loaded. | |
| MissingValue|mixed | whenCounted(string $relationship, mixed $value = null, mixed $default = null)
Retrieve a relationship count if it exists. | |
| MissingValue|mixed | whenAggregated(string $relationship, string $column, string $aggregate, mixed $value = null, mixed $default = null)
Retrieve a relationship aggregated value if it exists. | |
| MissingValue|mixed | whenPivotLoaded(string $table, mixed $value, mixed $default = null)
Execute a callback if the given pivot table has been loaded. | |
| MissingValue|mixed | whenPivotLoadedAs(string $accessor, string $table, mixed $value, mixed $default = null)
Execute a callback if the given pivot table with a custom accessor has been loaded. | |
| bool | hasPivotLoaded(string $table)
Determine if the resource has the specified pivot table loaded. | |
| bool | hasPivotLoadedAs(string $accessor, string $table)
Determine if the resource has the specified pivot table loaded with a custom accessor. | |
| mixed | transform(mixed $value, callable $callback, mixed $default = null)
Transform the given value if it is present. |
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.
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.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Http/Resources/ConditionallyLoadsAttributes.html