我是Laravel的新手和以下作品,但它对我来说似乎不是'Laravel' - 我只需要检测消息所指的验证规则(必需,电子邮件,唯一等):
@if ($errors->has('email'))
{{ $errors->first('email') }}
@if (strpos($errors->first('email'), 'has already been taken'))
{{ HTML::link('password', 'Need a reminder?', array(), FALSE); }}
@endif
@endif
有什么建议吗?
由于
答案 0 :(得分:1)
在你的控制器中,会做这样的事情(取决于它的配置方式)
<强>控制器强>
public function store()
{
$validator = Validator::make(Input::all(), array(
'name' => 'Dayle',
'email' => 'required|min:5'
));
if ($validator->passes())
{
// Redirect to success page or something
}
return Redirect::back()
->withInput()
->withErrors($validator)
->withFailed($validator->failed())
}
然后在你看来
查看强>
@if ($errors->has('email'))
The specific email rule that failed was: {{ $failed['email'] }}
@endif