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