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