Laravel update model with unique validation rule for attribute

后端 未结 18 2219
春和景丽
春和景丽 2020-11-27 12:45

I have a laravel User model which has a unique validation rule on username and email. In my Repository, when I update the model, I rev

18条回答
  •  臣服心动
    2020-11-27 13:10

    You can trying code bellow

    return [
        'email' => 'required|email|max:255|unique:users,email,' .$this->get('id'),
        'username' => 'required|alpha_dash|max:50|unique:users,username,'.$this->get('id'),
        'password' => 'required|min:6',
        'confirm-password' => 'required|same:password',
    ];
    

提交回复
热议问题