Laravel 5 如何在laravel 5中获得自定义错误页?
我需要一个自定义错误页面,例如404,而不是这个错误, 如果需要,您可以使用自定义错误消息进行验证,而不是使用默认值。有几种方法可以指定自定义消息。首先,您可以将自定义消息作为第三个参数传递给Validator::make方法:Laravel 5 如何在laravel 5中获得自定义错误页?,laravel-5,Laravel 5,我需要一个自定义错误页面,例如404,而不是这个错误, 如果需要,您可以使用自定义错误消息进行验证,而不是使用默认值。有几种方法可以指定自定义消息。首先,您可以将自定义消息作为第三个参数传递给Validator::make方法: $messages = [ 'required' => 'The :attribute field is required.', ]; $validator = Validator::make($input, $rules, $messages); 在
$messages = [
'required' => 'The :attribute field is required.',
];
$validator = Validator::make($input, $rules, $messages);
在本例中:属性placeholder将替换为验证中字段的实际名称。您还可以在验证消息中使用其他占位符。例如:
$messages = [
'same' => 'The :attribute and :other must match.',
'size' => 'The :attribute must be exactly :size.',
'between' => 'The :attribute must be between :min - :max.',
'in' => 'The :attribute must be one of the following types: :values',
];
或
为给定属性指定自定义消息
有时,您可能希望仅为特定字段指定自定义错误消息。您可以使用“点”符号来完成此操作。首先指定属性的名称,然后指定规则:
$messages = [
'email.required' => 'We need to know your e-mail address!',
];
请同时观看:
我不想对输入字段进行我已经做过的验证,我的问题是当我们从页面注销并单击浏览器中的“后退”按钮时,它会将我带到我在问题中发布的错误页面,而我想打开其他页面,例如404。