J
J
jazzus2019-03-05 20:58:27
Laravel
jazzus, 2019-03-05 20:58:27

How to specify message for User Rule in Laravel Request?

Made a Rule
NoUppercase
Connected in the request file I want to give a message in the same place, in the request file Can it be registered there? Or just pass a variable to the class and there already form a message in message. The fact is that I need to leave :attribute, but for name it displays the Name, and in this case I need the Name, so I want to form my message in the place where the need arises (i.e. in the request file)
'name' => array(new NoUppercase),
'name.no_uppercase' => Нельзя',

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crash XD, 2019-04-03
@crashxd

In RequestForm, you can override the messages function, where you can pass the necessary messages, under different rules.

public function messages()
    {
        return [
            'name.no_uppercase' => 'Нельзя',
            // ..
        ];
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question