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