Custom Laravel validation messages

后端 未结 6 1164
北恋
北恋 2020-12-23 13:07

I\'m trying to create customized messages for validation in Laravel 5. Here is what I have tried so far:

$messages = [
    \'required\'  => \'Harap bagian         


        
6条回答
  •  既然无缘
    2020-12-23 13:36

    Laravel 5.7.*

    Also You can try something like this. For me is the easiest way to make custom messages in methods when you want to validate requests:

    public function store()
    {
        request()->validate([
            'file' => 'required',
            'type' => 'required'
        ],
        [
            'file.required' => 'You have to choose the file!',
            'type.required' => 'You have to choose type of the file!'
        ]);
    }
    

提交回复
热议问题