2017-02-25 196 views
-2

类型错误:传递给App \ Http \ Controllers \ Controller :: validate()的参数1必须是在应用程序\ Http \ Controllers \ RegistrationController中调用的Illuminate \ Http \ Request,给定数组的实例。在线PHP 23Laravel请求验证错误

它不会在这里工作

Registration Controller

,但在同一时间,另一个控制器

AuthController

工作正常
+0

请去看[问]。 – CBroe

回答

1

你得到这个错误的原因是因为你通过你的验证规则给request()辅助功能,而不是作为第二参数去$this->validate()

你仍然可以使用request()辅助功能,但你只需要要做:

$this->validate(request(), [ 
    'name'  => 'required', 
    'email' => 'required|email', 
    'password' => 'password|confirmed', //<-- Is the password rule something you've created?!? 
]); 

希望这有助于!

+0

谢谢!这是我的问题的正确解决方案。 – akburan

0

function store()应该是function store(Request $request)如果您要使用请求。但是@CBroe是正确的:请学会更好地提出您的问题。

+0

我一直在努力制定这个特定的问题,我同意它不清楚。我发现我的错误,应该通过请求帮助器作为验证的第一个参数,并且要验证第二个参数的字段数组。 – akburan