I'm having difficulties detecting a unique username. I mean it does work to detect username but I would like to exclude the username validation if the request input username matches with that users current username in database.
Currently, I'm getting: The username has already been taken. despite the fact the its the same username as the one this user has in the database.
Thank you!
Rules
protected $rules = [
'username' =>
'nullable|string|alpha_dash|max:255|regex:/(^([a-zA-Z]+)(\d+)?$)/u|unique:users',
'first_name' => 'nullable|max:150',
'last_name' => 'nullable|max:150',
'location' => 'nullable|max:200',
'password' => 'confirmed'
];
Edit Profile POST method:
$validator = Validator::make($request->all(), $this->rules);
if ($validator->fails()) {
return \redirect()->back()->withErrors($validator->getMessageBag()->toArray())->withInput($request->except('image'));
} else {
$model = \App\User::find(\Auth::user()->id);