为什么我需要输入密码字段?

时间:2019-10-31 15:20:00

标签: php laravel

这是表单

<form class="signup-form" action="{{route('signup')}}" method="post">
    <input type="text" name="name" placeholder="Name" value="{{old('name')}}">
    <input type="text" name="email" placeholder="Email" value="{{old('email')}}">
    <input type="password" name="password" placeholder="Password">
    <input type="password" name="password_confirmation" placeholder="Confirm Password">
    <input type="hidden" name="_token" value="{{csrf_token()}}">
    <button type="submit" name="button">Sign Up</button>
</form>

这是路线

Route::get('home/registration', 'authController@showRegisterForm')->name('signup');
Route::post('home/registration', 'authController@register');

这是控制器

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use app\User;

class authController extends Controller
{
    public function showRegisterForm() {
        return view('registration');
    }

    public function register(Request $request) {
        $this->validation($request);
        return $request->all();
    }

    public function validation($request) {
        return $this->validate($request, [
            'name'=>'required|max:255',
            'email'=>'required|email|unique:users|max:255',
            'passsword'=>'required|confirmed|max:255',
        ]); 
    }
}

将验证放入控制器后出现错误。在进行验证之前,我已经检查了所有值是否都通过了请求,但是在进行验证之后,即使我输入了密码,也显示密码字段是必填字段。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

功能验证中存在密码拼写错误。