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

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

1 Answers1

0

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 {
    ...
}
Nikola Gavric
  • 3,507
  • 1
  • 8
  • 16
  • still not working :( it shows this under email "These credentials do not match our records." – S. Jamal Feb 21 '18 at 19:22
  • 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 – Nikola Gavric Feb 21 '18 at 19:40
  • 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 – S. Jamal Feb 21 '18 at 19:45
  • `"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` – Nikola Gavric Feb 21 '18 at 19:46
  • 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 – S. Jamal Feb 21 '18 at 20:09