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