JsonResource
Implements
Uses
Properties
$resource mixed
The resource instance.
$with array
The additional data that should be added to the top-level resource array.
$additional array
The additional meta data that should be added to the resource response.
Added during response construction by the developer.
$wrap string|null
The "data" wrapper that should be applied.
Methods
__construct ( $resource ) : void
Create a new resource instance.
Parameters
- $resource mixed
make ( $parameters ) : static
Create a new resource instance.
Parameters
- $parameters mixed
collection ( $resource ) : AnonymousResourceCollection
Create a new anonymous resource collection.
Parameters
- $resource mixed
newCollection ( $resource ) : AnonymousResourceCollection
Create a new resource collection instance.
Parameters
- $resource mixed
resolve ( $request ) : array
Resolve the resource to an array.
Parameters
- $request Request |null
toArray ( Request $request ) : array|Illuminate\...\Arrayable|JsonSerializable
Transform the resource into an array.
Parameters
- $request Request
toJson ( $options ) : string
Convert the model instance to JSON.
Parameters
- $options int
with ( Request $request ) : array
Get any additional data that should be returned with the resource array.
Parameters
- $request Request
additional ( array $data ) : $this
Add additional meta data to the resource response.
Parameters
- $data array
jsonOptions ( ) : int
Get the JSON serialization options that should be applied to the resource response.
withResponse ( Request $request , JsonResponse $response ) : void
Customize the response for a request.
Parameters
- $request Request
- $response JsonResponse
wrap ( $value ) : void
Set the string that should wrap the outer-most resource array.
Parameters
- $value string
withoutWrapping ( ) : void
Disable wrapping of the outer-most resource array.
response ( $request ) : JsonResponse
Transform the resource into an HTTP response.
Parameters
- $request Request |null
toResponse ( $request ) : JsonResponse
Create an HTTP response that represents the object.
Parameters
- $request Request
jsonSerialize ( ) : array
Prepare the resource for JSON serialization.