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