Custom Laravel validation messages

后端 未结 6 1141
北恋
北恋 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:30

    $rules = [
      'username' => 'required,unique:Userlogin,username',
      'password' => 'required',
      'email'    => 'required,unique:Userlogin,email'
    ];
    
    $messages = [
      'required'  => 'The :attribute field is required.',
      'unique'    => ':attribute is already used'
    ];
    
    $request->validate($rules,$messages);
    //only if validation success code below will be executed
    

提交回复
热议问题