ConditionallyLoadsAttributes
Methods
filter ( $data ) : array
Filter the given data, removing any optional values.
Parameters
- $data array
mergeData ( $data , $index , $merge , $numericKeys ) : array
Merge the given data in at the given index.
Parameters
- $data array
- $index int
- $merge array
- $numericKeys bool
removeMissingValues ( $data ) : array
Remove the missing values from the filtered data.
Parameters
- $data array
when ( $condition , $value , $default ) : MissingValue |mixed
Retrieve a value if the given "condition" is truthy.
Parameters
- $condition bool
- $value mixed
- $default mixed
unless ( $condition , $value , $default ) : MissingValue |mixed
Retrieve a value if the given "condition" is falsy.
Parameters
- $condition bool
- $value mixed
- $default mixed
merge ( $value ) : MergeValue |mixed
Merge a value into the array.
Parameters
- $value mixed
mergeWhen ( $condition , $value , $default ) : MergeValue |mixed
Merge a value if the given condition is truthy.
Parameters
- $condition bool
- $value mixed
- $default mixed
mergeUnless ( $condition , $value , $default ) : MergeValue |mixed
Merge a value unless the given condition is truthy.
Parameters
- $condition bool
- $value mixed
- $default mixed
attributes ( $attributes ) : MergeValue
Merge the given attributes.
Parameters
- $attributes array
whenHas ( $attribute , $value , $default ) : MissingValue |mixed
Retrieve an attribute if it exists on the resource.
Parameters
- $attribute string
- $value mixed
- $default mixed
whenNull ( $value , $default ) : MissingValue |mixed
Retrieve a model attribute if it is null.
Parameters
- $value mixed
- $default mixed
whenNotNull ( $value , $default ) : MissingValue |mixed
Retrieve a model attribute if it is not null.
Parameters
- $value mixed
- $default mixed
whenAppended ( $attribute , $value , $default ) : MissingValue |mixed
Retrieve an accessor when it has been appended.
Parameters
- $attribute string
- $value mixed
- $default mixed
whenLoaded ( $relationship , $value , $default ) : MissingValue |mixed
Retrieve a relationship if it has been loaded.
Parameters
- $relationship string
- $value mixed
- $default mixed
whenCounted ( $relationship , $value , $default ) : MissingValue |mixed
Retrieve a relationship count if it exists.
Parameters
- $relationship string
- $value mixed
- $default mixed
whenAggregated ( $relationship , $column , $aggregate , $value , $default ) : MissingValue |mixed
Retrieve a relationship aggregated value if it exists.
Parameters
- $relationship string
- $column string
- $aggregate string
- $value mixed
- $default mixed
whenPivotLoaded ( $table , $value , $default ) : MissingValue |mixed
Execute a callback if the given pivot table has been loaded.
Parameters
- $table string
- $value mixed
- $default mixed
whenPivotLoadedAs ( $accessor , $table , $value , $default ) : MissingValue |mixed
Execute a callback if the given pivot table with a custom accessor has been loaded.
Parameters
- $accessor string
- $table string
- $value mixed
- $default mixed
hasPivotLoaded ( $table ) : bool
Determine if the resource has the specified pivot table loaded.
Parameters
- $table string
hasPivotLoadedAs ( $accessor , $table ) : bool
Determine if the resource has the specified pivot table loaded with a custom accessor.
Parameters
- $accessor string
- $table string
transform ( $value , callable $callback , $default ) : mixed
Transform the given value if it is present.
Parameters
- $value mixed
- $callback callable
- $default mixed