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