ResourceCollection

class ResourceCollection extends Resource implements IteratorAggregate (View source)

Traits

CollectsResources
DelegatesToResource

Properties

mixed $resource The resource instance. from Resource
array $with The additional data that should be added to the top-level resource array. from Resource
array $additional The additional meta data that should be added to the resource response. from Resource
static string $wrap The "data" wrapper that should be applied. from Resource
string $collects The resource that this resource collects.
Collection $collection The mapped collection instance.

Methods

mixed getRouteKey()

Get the value of the resource's route key.

from DelegatesToResource
string getRouteKeyName()

Get the route key for the resource.

from DelegatesToResource
void resolveRouteBinding(mixed $value)

Retrieve the model for a bound value.

from DelegatesToResource
bool offsetExists(mixed $offset)

Determine if the given attribute exists.

from DelegatesToResource
mixed offsetGet(mixed $offset)

Get the value for a given offset.

from DelegatesToResource
void offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

from DelegatesToResource
void offsetUnset(mixed $offset)

Unset the value for a given offset.

from DelegatesToResource
bool __isset(string $key)

Determine if an attribute exists on the resource.

from DelegatesToResource
void __unset(string $key)

Unset an attribute on the resource.

from DelegatesToResource
mixed __get(string $key)

Dynamically get properties from the underlying resource.

from DelegatesToResource
mixed __call(string $method, array $parameters)

Dynamically pass method calls to the underlying resource.

from DelegatesToResource
void __construct(mixed $resource)

Create a new resource instance.

static Resource make(dynamic $parameters)

Create a new resource instance.

from Resource
static mixed collection(mixed $resource)

Create new anonymous resource collection.

from Resource
mixed collectResource(mixed $resource)

Map the given collection resource into its individual resources.

from CollectsResources
string|null collects()

Get the resource that this resource collects.

from CollectsResources
ArrayIterator getIterator()

Get an iterator for the resource collection.

from CollectsResources
array toArray(Request $request)

Transform the resource into a JSON array.

Response toResponse(Request $request)

Create an HTTP response that represents the object.

Details

mixed getRouteKey()

Get the value of the resource's route key.

Return Value

mixed

string getRouteKeyName()

Get the route key for the resource.

Return Value

string

void resolveRouteBinding(mixed $value)

Retrieve the model for a bound value.

Parameters

mixed $value

Return Value

void

Exceptions

Exception

bool offsetExists(mixed $offset)

Determine if the given attribute exists.

Parameters

mixed $offset

Return Value

bool

mixed offsetGet(mixed $offset)

Get the value for a given offset.

Parameters

mixed $offset

Return Value

mixed

void offsetSet(mixed $offset, mixed $value)

Set the value for a given offset.

Parameters

mixed $offset
mixed $value

Return Value

void

void offsetUnset(mixed $offset)

Unset the value for a given offset.

Parameters

mixed $offset

Return Value

void

bool __isset(string $key)

Determine if an attribute exists on the resource.

Parameters

string $key

Return Value

bool

void __unset(string $key)

Unset an attribute on the resource.

Parameters

string $key

Return Value

void

mixed __get(string $key)

Dynamically get properties from the underlying resource.

Parameters

string $key

Return Value

mixed

mixed __call(string $method, array $parameters)

Dynamically pass method calls to the underlying resource.

Parameters

string $method
array $parameters

Return Value

mixed

void __construct(mixed $resource)

Create a new resource instance.

Parameters

mixed $resource

Return Value

void

static Resource make(dynamic $parameters)

Create a new resource instance.

Parameters

dynamic $parameters

Return Value

Resource

static mixed collection(mixed $resource)

Create new anonymous resource collection.

Parameters

mixed $resource

Return Value

mixed

protected mixed collectResource(mixed $resource)

Map the given collection resource into its individual resources.

Parameters

mixed $resource

Return Value

mixed

protected string|null collects()

Get the resource that this resource collects.

Return Value

string|null

ArrayIterator getIterator()

Get an iterator for the resource collection.

Return Value

ArrayIterator

array toArray(Request $request)

Transform the resource into a JSON array.

Parameters

Request $request

Return Value

array

Response toResponse(Request $request)

Create an HTTP response that represents the object.

Parameters

Request $request

Return Value

Response

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.5/Illuminate/Http/Resources/Json/ResourceCollection.html