repository = $catalogo; parent::__construct(); } /** * Show catalogo's list. * * @param string $slug * * @return response */ protected function index() { $catalogos = $this->repository ->setPresenter('\\Renysh\\Turismo\\Repositories\\Presenter\\CatalogoListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $catalogos['code'] = 2000; return response()->json($catalogos) ->setStatusCode(200, 'INDEX_SUCCESS'); } /** * Show catalogo. * * @param string $slug * * @return response */ protected function show($slug) { $catalogo = $this->repository ->scopeQuery(function($query) use ($slug) { return $query->orderBy('id','DESC') ->where('slug', $slug); })->first(['*']); if (!is_null($catalogo)) { $catalogo = $this->itemPresenter($module, new CatalogoItemTransformer); $catalogo['code'] = 2001; return response()->json($catalogo) ->setStatusCode(200, 'SHOW_SUCCESS'); } else { return response()->json([]) ->setStatusCode(400, 'SHOW_ERROR'); } } }