app/Http/Controllers/Admin/AdminController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $request->validate([
            'admin_name' => 'required|unique:admin',
            'admin_tel' =>'required|max:11|min:11',
            'admin_email' =>'required',
            'admin_pwd' =>'required',
            'admin_pwds' =>'required',
        ],[
            'admin_name.required'=>'管理员名称必填！',
            'admin_name.unique'=>'管理员名称已存在！',
            'admin_tel.required'=>'手机号不能为空!',
            'admin_tel.max'=>'手机号格式不正确',
            'admin_tel.min'=>'手机号格式不正确!',
            'admin_email.required'=>'邮箱不能为空!',
            'admin_pwd.required'=>'密码不能为空!',
            'admin_pwds.required'=>'确认密码不能为空!',
        ]);
        $post = $request->except('_token');
        $post['admin_time'] = time();
         $post['admin_pwd'] = encrypt($post['admin_pwd']);
         unset($post['admin_pwds']);
        $res = Admin::create($post);
        if($res){
            return redirect('/admin');
        }
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'admin_name' => 'required|unique:admin' , 'admin_tel' => 'required|max:11|min:11' , 'admin_email' => 'required' , 'admin_pwd' => 'required' , 'admin_pwds' => 'required' , ] , [ 'admin_name.required' => '管理员名称必填！', 'admin_name.unique' => '管理员名称已存在！', 'admin_tel.required' => '手机号不能为空!', 'admin_tel.max' => '手机号格式不正确', 'admin_tel.min' => '手机号格式不正确!', 'admin_email.required' => '邮箱不能为空!', 'admin_pwd.required' => '密码不能为空!', 'admin_pwds.required' => '确认密码不能为空!', ] ) ; $ post = $ request -> except ( '_token' ) ; $ post [ 'admin_time' ] = time ( ) ; $ post [ 'admin_pwd' ] = encrypt ( $ post [ 'admin_pwd' ] ) ; unset ( $ post [ 'admin_pwds' ] ) ; $ res = Admin :: create ( $ post ) ; if ( $ res ) { return redirect ( '/admin' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
// //第一种验证 //dump($post); //dd($post);