1

How to translate keys from the validator attributes when it is array?

For example:

Here is validator with arrays 'image.author' and 'image.book'.

$validator = Validator::make($request->all(), [
    'title' => 'required|unique:posts|max:255',
    'body' => 'required',
    'image.author' => 'required',
    'image.book' => 'required',
]);

On validation.php exist these attributes.

'attributes' => [
    'image.author' => image of author',
    'image.book' => 'image of book',
],

If i use tinker to debug: __('validation.attributes.image.author');

"validation.attributes.image.author"

And the output corret should be:

"image of author"

francisco
  • 1,387
  • 2
  • 12
  • 23

1 Answers1

0

'author' and 'book' should be indexes of the 'images' index in the validation attributes array.

'attributes' => [
    'image' => [
        'author' => 'image of author',
        'book' => 'image of book',
    ],
],