Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

spawnia's avatar

@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
Previous

Please or to participate in this conversation.