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