I'm running a Laravel 8 project and I want to implement OAuth2. I successfully ran the following commands:
composer require laravel/ui --dev
php artisan ui vue --auth
composer require laravel/passport
php artisan migrate:refresh
php artisan passport:install
Then, I included Passport in the User model, like this:
<?php
namespace AppModels;
use IlluminateContractsAuthMustVerifyEmail;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;
use LaravelPassportHasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
];
.
.
.
But, it shows me an Undefined type error when I include the HasApiTokens trait:
How can I solve this?
question from:
https://stackoverflow.com/questions/65837358/undefined-type-laravel-passport-hasapitokens-when-trying-to-implement-oauth2 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…