Translation of array attributes from validator

Viewed 33

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"

0 Answers
Related