trait Illuminate / Http / Resources / ConditionallyLoadsAttributes

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 if the given "condition" is truthy.

Parameters

  • $condition bool
  • $value mixed
  • $default mixed
public

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

Retrieve a value if the given "condition" is falsy.

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 , $default ) : MergeValue |mixed

Merge a value if the given condition is truthy.

Parameters

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

mergeUnless ( $condition , $value , $default ) : MergeValue |mixed

Merge a value unless the given condition is truthy.

Parameters

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

attributes ( $attributes ) : MergeValue

Merge the given attributes.

Parameters

  • $attributes array
public

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

Retrieve an attribute if it exists on the resource.

Parameters

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

whenNull ( $value , $default ) : MissingValue |mixed

Retrieve a model attribute if it is null.

Parameters

  • $value mixed
  • $default mixed
protected

whenNotNull ( $value , $default ) : MissingValue |mixed

Retrieve a model attribute if it is not null.

Parameters

  • $value mixed
  • $default mixed
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
public

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

Retrieve a relationship count if it exists.

Parameters

  • $relationship string
  • $value mixed
  • $default mixed
public

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

hasPivotLoaded ( $table ) : bool

Determine if the resource has the specified pivot table loaded.

Parameters

  • $table string
protected

hasPivotLoadedAs ( $accessor , $table ) : bool

Determine if the resource has the specified pivot table loaded with a custom accessor.

Parameters

  • $accessor string
  • $table string
protected

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

Transform the given value if it is present.

Parameters

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