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