Some Error handling and acceptance tests

This commit is contained in:
Richard Morgan
2017-05-15 08:56:10 -04:00
parent 42dc785735
commit 2c8c692890
21 changed files with 457 additions and 126 deletions

View File

@@ -7,6 +7,15 @@ use League\Fractal\TransformerAbstract;
class FlightTransform extends TransformerAbstract
{
/**
* List of resources possible to include
*
* @var array
*/
protected $availableIncludes = [
'trips'
];
/**
* Turn this item object into a generic array
*
@@ -17,10 +26,23 @@ class FlightTransform extends TransformerAbstract
return [
'id' => $flight->id,
'name' => $flight->destination,
'trips' => $flight->trips()->get(),
'links' => [
'rel' => 'self',
'uri' => '/flights/'.$flight->id,
]
];
}
/**
* Include Trips
*
* @return \League\Fractal\Resource\ResourceAbstract
*/
public function includeTrips(Flights $flight)
{
$flights = $flight->trips()->get();
return $this->collection($flights, new TripTransformer());
}
}