<?php Class Que { /* * 查询: */ public function index() { $users = User::query()->paginate(20); return view(‘admin.user.index‘, [‘list‘ => $users]); $list = Category::get(); return view(‘admin.product.category.index‘, [‘list‘ => $list]); } /* *保存: */ public function store1() { $input = Input::except(‘_token‘); $rules = [ ‘cate_name‘ => ‘required‘, ]; $message = [ ‘cate_name.required‘ => ‘分类名称不能为空!‘, ]; $validator = Validator::make($input, $rules, $message); if ($validator->passes()) { $re = Category::create($input); if ($re) { return redirect(‘admin/category‘); } else { return back()->with(‘errors‘, ‘数据填充失败,请稍后重试!‘); } } else { return back()->withErrors($validator); } } public function store2(Request $request) { $input = $request->except(‘_token‘); $rules = [ ‘true_name‘ => ‘required‘, ‘mob_phone‘ => ‘required|regex:/^1\d{10}$/‘ ]; $message = [ ‘true_name.required‘ => ‘姓名不能为空‘, ‘mob_phone.required‘ => ‘电话号码不能为空‘, ‘mob_phone.regex‘ => ‘电话号码不符合要求‘ ]; $validator = Validator::make($input, $rules, $message); if ($validator->passes()) { $re = Address::create($input); if ($re) { return redirect(‘member/address‘); } else { return back()->with(‘errors‘, ‘地址提交失败‘); } } else { return back()->withErrors($validator); } return redirect(‘Member\[email protected]‘); } /* * delete */ public function destroy($id) { Address::where(‘address_id‘, ‘=‘, $id)->delete(); return redirect(‘member/address‘); } }
时间: 2024-10-13 00:41:17