/** * @param array $vehicle * @param boolean $showHref * @return array */ public function transform($vehicle, $showHref = false) { $data = ['id' => $vehicle->id, 'year' => $vehicle->year, 'mileage' => $vehicle->mileage, 'vin' => $vehicle->vin, 'links' => ['make' => $this->makeTransformer->transform($vehicle->model->make, true), 'model' => $this->modelTransformer->transform($vehicle->model, true)]]; if ($showHref) { $data['href'] = route('vehicles.show', ['id' => $vehicle->id]); } return $data; }
/** * Display the specified resource. * GET /models/{id} * * @param int $id * @return Response */ public function show($id) { try { $model = Model::findOrFail($id); } catch (ModelNotFoundException $e) { return $this->respondNotFound('Model does not exist'); } return $this->respondOk(['model' => $this->modelTransformer->transform($model)]); }