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