Formatter
class Formatter
Properties
string | $content_type | The Content-Type this Formatter returns. | |
protected ModelMapping | $mapping | Holds the mapping used to determine the appropriate Transformer for each Model. | |
protected Controller | $controller | Holds the instanced of the calling controller. |
Methods
__construct(
ModelMapping $mapping,
Controller $controller)
Create a new instance.
string
format(
mixed $data)
Generate a HTTP response body from an Eloquent Collection or Model.
Array
formatResource(
Model $model)
Format a single record.
Array
formatCollection(
Collection $collection)
Format an entire collection.
String
serialize(
Array $data)
Turn the transformed data into a JSON string.
Array
transform(
Model $model)
Apply the transformer to an Eloquent Model.
Details
at line line 42
__construct(
ModelMapping $mapping,
Controller $controller)
Create a new instance.
at line line 55
string
format(
mixed $data)
Generate a HTTP response body from an Eloquent Collection or Model.
at line line 75
protected
Array
formatResource(
Model $model)
Format a single record.
at line line 86
protected
Array
formatCollection(
Collection $collection)
Format an entire collection.
at line line 100
protected
String
serialize(
Array $data)
Turn the transformed data into a JSON string.
at line line 111
protected
Array
transform(
Model $model)
Apply the transformer to an Eloquent Model.