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

OG_Neverland's avatar

How to modify a credential auth in laravel 12 livewire starter kit?

So, I have an idea for built a web app counseling for school support, and I want the credentials is using a student id and for teacher also using teacher id, but for admin using an email or maybe can use an custom username too. But how i modify a laravel 12 livewire starter kit? any solutions for this? thank you if you guys give me a feedback or answer

1 like
1 reply
jlrdw's avatar

and I want the credentials is using a student id

Doable yes but just think about:

What if Bob happens to find out Joe's id? But you can use id, a username, instead of email, just change code where needed.

Just example of one of my apps.

    public function authenticate(Request $request)
    {
        $credentials = $request->only('username', 'password');

        if (Auth::attempt($credentials)) {
            $request->session()->regenerate();
            $path = $this->getRedirect();     // my custom function

            return redirect()->intended($path);
        }
        $message = 'The provided credentials do not match our records.';
        return redirect('login')->with('status', $message);

    }

And see https://laravel.com/docs/12.x/authentication#authenticate-a-user-by-id

Please or to participate in this conversation.