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