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

ronyamin's avatar

How to get user's date of birth?

I am creating a student project in Laravel. I have created all my models including the student model. I want to use the student_number(index_number) and the students date_of_birth from the student model as login credential for the front end view instead of the default user login(email and password). I do not want users to register before they can login as in the default laravel welcome page.

0 likes
1 reply
tisuchi's avatar
tisuchi
Best Answer
Level 70

There are many ways to move with this issue.

Try this-

public function login() {
  $user = User::where('index_number', request('index_number'))->first();
  if($user->birthday != request('birthday')) {
    return 'Invalid Credentials';
  }

  \Auth::login($user);

  return 'login success'
}

Check more in- https://laravel.com/docs/6.x/authentication

10 likes

Please or to participate in this conversation.