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