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