Level 1
@arabsight I like your solution the most so far, here is some slight improvement to make it even more simple:
/**
* Get the login username to be used by the controller.
*
* Depending on if the given input is of the type email, it is passed along as either
* the name or email of the user.
*
* @return string
*/
public function username()
{
$field = filter_var(request('login'), FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
request()->merge([$field => request('login')]);
return $field;
}
1 like