I have a user model class that has class User extends Authenticatable
and another model class that I also created that has class Foo extends Model
it's causing some issues in displaying data from the routes files and I am pretty sure it has something to do with the 'Authenticatable' part because for Foo, the information displays correctly, but for User, it doesn't, even with the same code.
What's the difference between these two classes/models?
If you look at the imports it shows:
use Illuminate\Foundation\Auth\User as Authenticatable;
This means Authenticatable
is an alias to Illuminate\Foundation\Auth\User
.
If you look into the source code of Illuminate\Foundation\Auth\User
it shows:
class User extends Model implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
}
Basically Authenticatable
is the same as a normal model, but adds the following traits:
Authenticatable
Authorizable
CanResetPassword
MustVerifyEmail
This is used by authentication, and adds the following methods:
getAuthIdentifierName()
getAuthIdentifier()
getAuthPassword()
getRememberToken()
setRememberToken()
getRememberTokenName()
This is used to determine if a User is able to perform certain abilities. It has the following methods:
can()
canAny()
cant()
cannot()
Used for resetting passwords. It has the following methods
getEmailForPasswordReset()
sendPasswordResetNotification()
Used for verifying emails if your using that feature. It has the following methods:
hasVerifiedEmail()
markEmailAsVerified()
sendEmailVerificationNotification()
getEmailForVerification()
I recommend try having a look at the source code yourself to get a better understanding what these traits do.
Also, based on the above, I doubt it will have any issues with your data in the route files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With