M
M
Maxim Akhmerov2018-02-13 10:57:57
Laravel
Maxim Akhmerov, 2018-02-13 10:57:57

Question about authentication in laravel, how to change the default user correctly?

Laravel has a standard user that inherits from Authenticatable, but I use a database that has a student that inherits from the Model class to register links between other classes. I want to make one class, a student, so that it extends Model (for relationships with other tables) and extends Authenticatable so that it can be used for registration / authorization. Tell me how to do this or is it even possible to do this?
so far, when registering, a default user is created for me, when it is created with the same id, a student is created, the data of which is filled in by a person.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Overfinch, 2018-02-13
@Overfinch

Authenticatable differs from the regular model in that it uses these three traits
Illuminate\Auth\Authenticatable
Illuminate\Auth\Passwords\CanResetPassword
Illuminate\Foundation\Auth\Access\Authorizable
And implements these interfaces
Illuminate\Contracts\Auth\Authenticatable
Illuminate\Contracts\Auth \Access\Authorizable
Illuminate\Contracts\Auth\CanResetPassword

A
anlamas, 2018-02-16
@anlamas

Create a class Student and inherit from User
class Student extends User
As a result, everything will be available to you.
User extends Authenticatable(Illuminate\Foundation\Auth\User as Authenticatable)
Authenticatable(Illuminate\Foundation\Auth\User as Authenticatable) extends Model

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question