hi guys i have a problem in change message error in validation i wanna change it to french but i don't know how can i do it this my code :
public function rules()
{
return [
'name' => ['required', 'string'],
'group_id' => 'nullable|integer|exists:groups,id',
];
}
public function attributes()
{
return [
'name' => 'nom',
'group_id' => "ID de group"
];
}
but in response show me "group id " Not "ID de group"
CodePudding user response:
You need to override the messages
function in the form request specifying a message for each rule you want to customise.
public function messages()
{
return [
'name.required' => 'nom',
'group_id.integer' => "ID de group"
];
}
CodePudding user response:
Is rest of the text translated?
If so then I think what you need is to specify name of translations file:
public function attributes()
{
return [
'name' => '[FILE_NAME].name',
'group_id' => '[FILE_NAME].group_id'
];
}
and in your resources / lang / fr / [FILE_NAME].php
you need:
<?php
return [
// Other translations
'name' => 'nom',
'group_id' => 'ID de group',
// Other translations
];