AnonymousResourceCollection
class AnonymousResourceCollection extends ResourceCollection (View source)
Traits
Properties
mixed | $resource | The resource instance. | from JsonResource |
array | $with | The additional data that should be added to the top-level resource array. | from JsonResource |
array | $additional | The additional meta data that should be added to the resource response. | from JsonResource |
static string | $wrap | The "data" wrapper that should be applied. | from JsonResource |
string | $collects | The name of the resource being collected. | |
Collection | $collection | The mapped collection instance. | from ResourceCollection |
Methods
Filter the given data, removing any optional values.
Merge the given data in at the given index.
Remove the missing values from the filtered data.
Retrieve a value based on a given condition.
Merge a value into the array.
Merge a value based on a given condition.
Merge the given attributes.
Retrieve a relationship if it has been loaded.
Execute a callback if the given pivot table has been loaded.
Transform the given value if it is present.
Retrieve the model for a bound value.
Set the value for a given offset.
Determine if an attribute exists on the resource.
Dynamically get properties from the underlying resource.
Dynamically pass method calls to the underlying resource.
Create a new anonymous resource collection.
Create new anonymous resource collection.
Set the string that should wrap the outer-most resource array.
Map the given collection resource into its individual resources.
Details
protected array
filter(array $data)
Filter the given data, removing any optional values.
protected array
mergeData(array $data, int $index, array $merge, bool $numericKeys)
Merge the given data in at the given index.
protected array
removeMissingValues(array $data, bool $numericKeys = false)
Remove the missing values from the filtered data.
protected MissingValue|mixed
when(bool $condition, mixed $value, mixed $default = null)
Retrieve a value based on a given condition.
protected MergeValue|mixed
merge(mixed $value)
Merge a value into the array.
protected MergeValue|mixed
mergeWhen(bool $condition, mixed $value)
Merge a value based on a given condition.
protected MergeValue
attributes(array $attributes)
Merge the given attributes.
protected MissingValue|mixed
whenLoaded(string $relationship, mixed $value = null, mixed $default = null)
Retrieve a relationship if it has been loaded.
protected MissingValue|mixed
whenPivotLoaded(string $table, mixed $value, mixed $default = null)
Execute a callback if the given pivot table has been loaded.
protected mixed
transform(mixed $value, callable $callback, mixed $default = null)
Transform the given value if it is present.
in DelegatesToResource at line 14
mixed
getRouteKey()
Get the value of the resource's route key.
in DelegatesToResource at line 24
string
getRouteKeyName()
Get the route key for the resource.
in DelegatesToResource at line 36
void
resolveRouteBinding(mixed $value)
Retrieve the model for a bound value.
in DelegatesToResource at line 47
bool
offsetExists(mixed $offset)
Determine if the given attribute exists.
in DelegatesToResource at line 58
mixed
offsetGet(mixed $offset)
Get the value for a given offset.
in DelegatesToResource at line 70
void
offsetSet(mixed $offset, mixed $value)
Set the value for a given offset.
in DelegatesToResource at line 81
void
offsetUnset(mixed $offset)
Unset the value for a given offset.
in DelegatesToResource at line 92
bool
__isset(string $key)
Determine if an attribute exists on the resource.
in DelegatesToResource at line 103
void
__unset(string $key)
Unset an attribute on the resource.
in DelegatesToResource at line 114
mixed
__get(string $key)
Dynamically get properties from the underlying resource.
in DelegatesToResource at line 126
mixed
__call(string $method, array $parameters)
Dynamically pass method calls to the underlying resource.
at line 21
void
__construct(mixed $resource, string $collects)
Create a new anonymous resource collection.
in JsonResource at line 66
static JsonResource
make(mixed ...$parameters)
Create a new resource instance.
in JsonResource at line 77
static AnonymousResourceCollection
collection(mixed $resource)
Create new anonymous resource collection.
in JsonResource at line 88
array
resolve(Request|null $request = null)
Resolve the resource to an array.
in ResourceCollection at line 46
array
toArray(Request $request)
Transform the resource into a JSON array.
in JsonResource at line 124
array
with(Request $request)
Get any additional data that should be returned with the resource array.
in JsonResource at line 135
$this
additional(array $data)
Add additional meta data to the resource response.
in JsonResource at line 149
void
withResponse(Request $request, JsonResponse $response)
Customize the response for a request.
in JsonResource at line 160
static void
wrap(string $value)
Set the string that should wrap the outer-most resource array.
in JsonResource at line 170
static void
withoutWrapping()
Disable wrapping of the outer-most resource array.
in JsonResource at line 181
JsonResponse
response(Request|null $request = null)
Transform the resource into an HTTP response.
in ResourceCollection at line 57
Response
toResponse(Request $request)
Create an HTTP response that represents the object.
in JsonResource at line 204
array
jsonSerialize()
Prepare the resource for JSON serialization.
in CollectsResources at line 16
protected mixed
collectResource(mixed $resource)
Map the given collection resource into its individual resources.
in CollectsResources at line 38
protected string|null
collects()
Get the resource that this resource collects.
in CollectsResources at line 55
ArrayIterator
getIterator()
Get an iterator for the resource collection.