ResourceCollection
extends Resource
in package
implements
IteratorAggregate
Uses
CollectsResources
Interfaces, Classes and Traits
- IteratorAggregate
Table of Contents
- $additional : array<string|int, mixed>
- The additional meta data that should be added to the resource response.
- $collection : Collection
- The mapped collection instance.
- $collects : string
- The resource that this resource collects.
- $resource : mixed
- The resource instance.
- $with : array<string|int, mixed>
- The additional data that should be added to the top-level resource array.
- $wrap : string
- The "data" wrapper that should be applied.
- __call() : mixed
- Dynamically pass method calls to the underlying resource.
- __construct() : void
- Create a new resource instance.
- __get() : mixed
- Dynamically get properties from the underlying resource.
- __isset() : bool
- Determine if an attribute exists on the resource.
- __unset() : void
- Unset an attribute on the resource.
- additional() : $this
- Add additional meta data to the resource response.
- collection() : AnonymousResourceCollection
- Create new anonymous resource collection.
- getIterator() : ArrayIterator
- Get an iterator for the resource collection.
- getRouteKey() : mixed
- Get the value of the resource's route key.
- getRouteKeyName() : string
- Get the route key for the resource.
- jsonSerialize() : array<string|int, mixed>
- Prepare the resource for JSON serialization.
- make() : static
- Create a new resource instance.
- offsetExists() : bool
- Determine if the given attribute exists.
- offsetGet() : mixed
- Get the value for a given offset.
- offsetSet() : void
- Set the value for a given offset.
- offsetUnset() : void
- Unset the value for a given offset.
- resolve() : array<string|int, mixed>
- Resolve the resource to an array.
- resolveRouteBinding() : void
- Retrieve the model for a bound value.
- response() : JsonResponse
- Transform the resource into an HTTP response.
- toArray() : array<string|int, mixed>
- Transform the resource into a JSON array.
- toResponse() : JsonResponse
- Create an HTTP response that represents the object.
- with() : array<string|int, mixed>
- Get any additional data that should be returned with the resource array.
- withoutWrapping() : void
- Disable wrapping of the outer-most resource array.
- withResponse() : void
- Customize the response for a request.
- wrap() : void
- Set the string that should wrap the outer-most resource array.
- attributes() : MergeValue
- Merge the given attributes.
- collectResource() : mixed
- Map the given collection resource into its individual resources.
- collects() : string|null
- Get the resource that this resource collects.
- filter() : array<string|int, mixed>
- Filter the given data, removing any optional values.
- merge() : array<string|int, mixed>
- Merge the given data in at the given index.
- mergeWhen() : MissingValue|mixed
- Merge a value based on a given condition.
- transform() : mixed
- Transform the given value if it is present.
- when() : MissingValue|mixed
- Retrieve a value based on a given condition.
- whenLoaded() : MissingValue|mixed
- Retrieve a relationship if it has been loaded.
- whenPivotLoaded() : MissingValue|mixed
- Execute a callback if the given pivot table has been loaded.
Properties
$additional
The additional meta data that should be added to the resource response.
public
array<string|int, mixed>
$additional
= []
Added during response construction by the developer.
$collection
The mapped collection instance.
public
Collection
$collection
$collects
The resource that this resource collects.
public
string
$collects
$resource
The resource instance.
public
mixed
$resource
$with
The additional data that should be added to the top-level resource array.
public
array<string|int, mixed>
$with
= []
$wrap
The "data" wrapper that should be applied.
public
static string
$wrap
= 'data'
Methods
__call()
Dynamically pass method calls to the underlying resource.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Return values
mixed —__construct()
Create a new resource instance.
public
__construct(mixed $resource) : void
Parameters
- $resource : mixed
Return values
void —__get()
Dynamically get properties from the underlying resource.
public
__get(string $key) : mixed
Parameters
- $key : string
Return values
mixed —__isset()
Determine if an attribute exists on the resource.
public
__isset(string $key) : bool
Parameters
- $key : string
Return values
bool —__unset()
Unset an attribute on the resource.
public
__unset(string $key) : void
Parameters
- $key : string
Return values
void —additional()
Add additional meta data to the resource response.
public
additional(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$this —collection()
Create new anonymous resource collection.
public
static collection(mixed $resource) : AnonymousResourceCollection
Parameters
- $resource : mixed
Return values
AnonymousResourceCollection —getIterator()
Get an iterator for the resource collection.
public
getIterator() : ArrayIterator
Return values
ArrayIterator —getRouteKey()
Get the value of the resource's route key.
public
getRouteKey() : mixed
Return values
mixed —getRouteKeyName()
Get the route key for the resource.
public
getRouteKeyName() : string
Return values
string —jsonSerialize()
Prepare the resource for JSON serialization.
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —make()
Create a new resource instance.
public
static make(dynamic ...$parameters) : static
Parameters
- $parameters : dynamic
Return values
static —offsetExists()
Determine if the given attribute exists.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
bool —offsetGet()
Get the value for a given offset.
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —offsetSet()
Set the value for a given offset.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Return values
void —offsetUnset()
Unset the value for a given offset.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Return values
void —resolve()
Resolve the resource to an array.
public
resolve([Request|null $request = null ]) : array<string|int, mixed>
Parameters
- $request : Request|null = null
Return values
array<string|int, mixed> —resolveRouteBinding()
Retrieve the model for a bound value.
public
resolveRouteBinding(mixed $value) : void
Parameters
- $value : mixed
Tags
Return values
void —response()
Transform the resource into an HTTP response.
public
response([Request|null $request = null ]) : JsonResponse
Parameters
- $request : Request|null = null
Return values
JsonResponse —toArray()
Transform the resource into a JSON array.
public
toArray(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Return values
array<string|int, mixed> —toResponse()
Create an HTTP response that represents the object.
public
toResponse(Request $request) : JsonResponse
Parameters
- $request : Request
Return values
JsonResponse —with()
Get any additional data that should be returned with the resource array.
public
with(Request $request) : array<string|int, mixed>
Parameters
- $request : Request
Return values
array<string|int, mixed> —withoutWrapping()
Disable wrapping of the outer-most resource array.
public
static withoutWrapping() : void
Return values
void —withResponse()
Customize the response for a request.
public
withResponse(Request $request, JsonResponse $response) : void
Parameters
- $request : Request
- $response : JsonResponse
Return values
void —wrap()
Set the string that should wrap the outer-most resource array.
public
static wrap(string $value) : void
Parameters
- $value : string
Return values
void —attributes()
Merge the given attributes.
protected
attributes(array<string|int, mixed> $attributes) : MergeValue
Parameters
- $attributes : array<string|int, mixed>
Return values
MergeValue —collectResource()
Map the given collection resource into its individual resources.
protected
collectResource(mixed $resource) : mixed
Parameters
- $resource : mixed
Return values
mixed —collects()
Get the resource that this resource collects.
protected
collects() : string|null
Return values
string|null —filter()
Filter the given data, removing any optional values.
protected
filter(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
Return values
array<string|int, mixed> —merge()
Merge the given data in at the given index.
protected
merge(array<string|int, mixed> $data, int $index, array<string|int, mixed> $merge) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $index : int
- $merge : array<string|int, mixed>
Return values
array<string|int, mixed> —mergeWhen()
Merge a value based on a given condition.
protected
mergeWhen(bool $condition, mixed $value) : MissingValue|mixed
Parameters
- $condition : bool
- $value : mixed
Return values
MissingValue|mixed —transform()
Transform the given value if it is present.
protected
transform(mixed $value, callable $callback[, mixed $default = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable
- $default : mixed = null
Return values
mixed —when()
Retrieve a value based on a given condition.
protected
when(bool $condition, mixed $value[, mixed $default = null ]) : MissingValue|mixed
Parameters
- $condition : bool
- $value : mixed
- $default : mixed = null
Return values
MissingValue|mixed —whenLoaded()
Retrieve a relationship if it has been loaded.
protected
whenLoaded(string $relationship[, mixed $value = null ][, mixed $default = null ]) : MissingValue|mixed
Parameters
- $relationship : string
- $value : mixed = null
- $default : mixed = null
Return values
MissingValue|mixed —whenPivotLoaded()
Execute a callback if the given pivot table has been loaded.
protected
whenPivotLoaded(string $table, mixed $value[, mixed $default = null ]) : MissingValue|mixed
Parameters
- $table : string
- $value : mixed
- $default : mixed = null