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