我有以下代码:
'attributes' => array(
'first_name' => 'voornaam'
, 'first name' => 'voornaam'
, 'firstname' => 'voornaam'
);
用于显示错误:
@if($errors->has())
<ul>
@foreach ($errors->all() as $error)
<li class="help-inline errorColor">{{ $error }}</li>
@endforeach
</ul>
@endif
还有控制器中的验证:
$validation = Validator::make($input, $rules, $messages);
$messages 数组:
$messages = array(
'required' => ':attribute is verplicht.'
, 'email' => ':attribute is geen geldig e-mail adres.'
, 'min' => ':attribute moet minimaal :min karakters bevatten.'
, 'numeric' => ':attribute mag alleen cijfers bevatten.'
, 'url' => ':attribute moet een valide url zijn.'
, 'unique' => ':attribute moet uniek zijn.'
, 'max' => ':attribute mag maximaal :max zijn.'
, 'mimes' => ':attribute moet een :mimes bestand zijn.'
, 'numeric' => ':attribute is geen geldig getal.'
, 'size' => ':attribute is te groot of bevat te veel karakters.'
);
请问我做错了什么?我希望在属性数组(language)中用“漂亮的名字”替换掉:attribute名称。
谢谢!
编辑:
我发现问题在于我没有为我的Laravel项目设置默认语言。当我将语言设置为'NL'时,上面的代码可以正常工作。但是,当我设置我的语言时,语言会出现在URL中。而我希望它不会出现在那里。
所以我的下一个问题是:是否可能从URL中删除语言,或者设置默认语言,使其不会显示在那里?