paginate(20); return view('admin.department.index', compact('data')); } public function edit($dep_id) { if (!$data = Department::find($dep_id)) return back()->withErrors('未找到数据'); return view('admin.department.edit', compact('data')); } public function create() { return view('admin.department.create'); } public function update(DepartmentRequest $request, $dep_id) { if (!Department::where('id', $dep_id)->update($request->except('_token', '_method'))) return back()->withErrors('机构信息更新失败,请稍后重试!'); return redirect('/department'); } public function destroy($dep_id) { if (!Department::where('id', $dep_id)->delete()) return ['status' => 0, 'msg' => '删除失败,请刷新重试!']; return ['status' => 1, 'msg' => '删除成功!']; } public function store(DepartmentRequest $request) { $input = $request->except('_token'); $input['display'] = '1'; if (!Department::create($input)) return back()->withErrors('新建失败,请稍后重试!'); return redirect('/department'); } public function ting($dep_id) { if (!Department::where('id', $dep_id)->update(['display' => 0])) return ['status' => '0', 'msg' => '隐藏失败!']; return ['status' => '1','msg' => '隐藏成功!']; } public function start($dep_id) { if (!Department::where('id', $dep_id)->update(['display' => 1])) return ['status' => '0', 'msg' => '显示失败!']; return ['status' => '1','msg' => '显示成功!']; } }