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