app/Http/Controllers/Admin/AdminController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $post = $request->except('_token');
        $request->validate([
            'admin_name' => 'required|unique:admin',
            'admin_tel' =>'required|max:11|min:11',
            'admin_email' =>'required',
        ],[
            'admin_name.required'=>'管理员名称必填！',
            'admin_name.unique'=>'管理员名称已存在！',
            'admin_tel.required'=>'手机号不能为空!',
            'admin_tel.max'=>'手机号格式不正确',
            'admin_tel.min'=>'手机号格式不正确!',
            'admin_email.required'=>'邮箱不能为空!',
        ]);
          $res = Admin::where('admin_id',$id)->update($post);
        if($res!==false){
            return redirect('/admin');
        }
    }
public function update ( Request $ request , $ id ) { $ post = $ request -> except ( '_token' ) ; $ request -> validate ( [ 'admin_name' => 'required|unique:admin' , 'admin_tel' => 'required|max:11|min:11' , 'admin_email' => 'required' , ] , [ 'admin_name.required' => '管理员名称必填！', 'admin_name.unique' => '管理员名称已存在！', 'admin_tel.required' => '手机号不能为空!', 'admin_tel.max' => '手机号格式不正确', 'admin_tel.min' => '手机号格式不正确!', 'admin_email.required' => '邮箱不能为空!', ] ) ; $ res = Admin :: where ( 'admin_id' , $ id ) -> update ( $ post ) ; if ( $ res !== false ) { return redirect ( '/admin' ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .
// //第一种验证