*/ public function index(GetEggsRequest $request): array { return $this->fractal->collection(Egg::all()) ->transformWith($this->getTransformer(EggTransformer::class)) ->toArray(); } /** * View egg * * Return a single egg that exists * * @return array */ public function view(GetEggRequest $request, Egg $egg): array { return $this->fractal->item($egg) ->transformWith($this->getTransformer(EggTransformer::class)) ->toArray(); } /** * Export egg * * Return a single egg as yaml or json file (defaults to YAML) */ public function export(ExportEggRequest $request, Egg $egg): StreamedResponse { $format = EggFormat::tryFrom($request->input('format')) ?? EggFormat::YAML; return response()->streamDownload(function () use ($egg, $format) { echo $this->exporterService->handle($egg->id, $format); }, 'egg-' . $egg->getKebabName() . '.' . $format->value, [ 'Content-Type' => 'application/' . $format->value, ]); } }