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