1

I'm trying to make another table called students, and i want to connect login with it instead of users table this because "users" name cause problem on my database.

Initially for register i wrote my own code by creating students table and store records on it and it works successfully.

But for the login, i prefer to use laravel login but with students table is there clear steps or something like this? i want to never use "users" table

2
  • 1
    If you're using a User model, you can just set $table = "students" on the class. Commented Feb 21, 2018 at 18:49
  • change table name not working also :( and i thing it's not duplicate because i want to never use "users" table Commented Feb 21, 2018 at 19:27

1 Answer 1

1

You can change your auth.php, providers array like this:

'providers' => [
    'users' => [
        ...
        'model' => App\Student::class,
    ],
    ...
 ]

And then update your user model like this:

...
use Illuminate\Foundation\Auth\User as Authenticatable; //remove this line
use Illuminate\Database\Eloquent\Model; //Add this line

class User extends Model {
     ...
}

Then change your Students class to following:

...
use Illuminate\Foundation\Auth\User as Authenticatable; //Add this
...

class Student extends Authenticatable {
    ...
}
Sign up to request clarification or add additional context in comments.

5 Comments

still not working :( it shows this under email "These credentials do not match our records."
That error is thrown when the user is not found inside the database..That doesn't mean that something you asked "how to" doesn't work
yes but the email exist on the database on students table, so I understood from this error that he did not reach the required table "students" and thus i say that the solution did not work
"These credentials do not match our records." means that the student in your case wasn't found with the requested email AND password, not just email
Thank you very much! you saved me ! my error is that i have "Email" column on my table instead of "email" and "Password" instead of "password", your solution works after i have modified them

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.