trait Illuminate / Http / Resources / ConditionallyLoadsAttributes
You are viewing an older version of the documentation. For the latest, please visit master documentation.

ConditionallyLoadsAttributes

Methods

protected

filter ( $data ) : array

Filter the given data, removing any optional values.

Parameters

  • $data array
protected

mergeData ( $data , $index , $merge , $numericKeys ) : array

Merge the given data in at the given index.

Parameters

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

removeMissingValues ( $data ) : array

Remove the missing values from the filtered data.

Parameters

  • $data array
protected

when ( $condition , $value , $default ) : MissingValue |mixed

Retrieve a value based on a given condition.

Parameters

  • $condition bool
  • $value mixed
  • $default mixed
protected

merge ( $value ) : MergeValue |mixed

Merge a value into the array.

Parameters

  • $value mixed
protected

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

Merge a value based on a given condition.

Parameters

  • $condition bool
  • $value mixed
protected

attributes ( $attributes ) : MergeValue

Merge the given attributes.

Parameters

  • $attributes array
protected

whenAppended ( $attribute , $value , $default ) : MissingValue |mixed

Retrieve an accessor when it has been appended.

Parameters

  • $attribute string
  • $value mixed
  • $default mixed
protected

whenLoaded ( $relationship , $value , $default ) : MissingValue |mixed

Retrieve a relationship if it has been loaded.

Parameters

  • $relationship string
  • $value mixed
  • $default mixed
protected

whenPivotLoaded ( $table , $value , $default ) : MissingValue |mixed

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

Parameters

  • $table string
  • $value mixed
  • $default mixed
protected

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
protected

transform ( $value , callable $callback , $default ) : mixed

Transform the given value if it is present.

Parameters

  • $value mixed
  • $callback callable
  • $default mixed