trait ConditionallyLoadsAttributes (View source)

Methods

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 based on a given condition.

MergeValue|mixed
merge(mixed $value)

Merge a value into the array.

MergeValue|mixed
mergeWhen(bool $condition, mixed $value)

Merge a value based on a given condition.

attributes(array $attributes)

Merge the given attributes.

MissingValue|mixed
whenLoaded(string $relationship, mixed $value = null, mixed $default = null)

Retrieve a relationship if it has been loaded.

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.

mixed
transform(mixed $value, callable $callback, mixed $default = null)

Transform the given value if it is present.

Details

protected array filter(array $data)

Filter the given data, removing any optional values.

Parameters

array $data

Return Value

array

protected array mergeData(array $data, int $index, array $merge, bool $numericKeys)

Merge the given data in at the given index.

Parameters

array $data
int $index
array $merge
bool $numericKeys

Return Value

array

protected array removeMissingValues(array $data)

Remove the missing values from the filtered data.

Parameters

array $data

Return Value

array

protected MissingValue|mixed when(bool $condition, mixed $value, mixed $default = null)

Retrieve a value based on a given condition.

Parameters

bool $condition
mixed $value
mixed $default

Return Value

MissingValue|mixed

protected MergeValue|mixed merge(mixed $value)

Merge a value into the array.

Parameters

mixed $value

Return Value

MergeValue|mixed

protected MergeValue|mixed mergeWhen(bool $condition, mixed $value)

Merge a value based on a given condition.

Parameters

bool $condition
mixed $value

Return Value

MergeValue|mixed

protected MergeValue attributes(array $attributes)

Merge the given attributes.

Parameters

array $attributes

Return Value

MergeValue

protected MissingValue|mixed whenLoaded(string $relationship, mixed $value = null, mixed $default = null)

Retrieve a relationship if it has been loaded.

Parameters

string $relationship
mixed $value
mixed $default

Return Value

MissingValue|mixed

protected MissingValue|mixed whenPivotLoaded(string $table, mixed $value, mixed $default = null)

Execute a callback if the given pivot table has been loaded.

Parameters

string $table
mixed $value
mixed $default

Return Value

MissingValue|mixed

protected 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.

Parameters

string $accessor
string $table
mixed $value
mixed $default

Return Value

MissingValue|mixed

protected mixed transform(mixed $value, callable $callback, mixed $default = null)

Transform the given value if it is present.

Parameters

mixed $value
callable $callback
mixed $default

Return Value

mixed