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