【发布时间】:2018-05-07 21:19:34
【问题描述】:
我正在运行 Lumen (5.6.3) (Laravel Components 5.6.*)。我正在尝试使用本教程(https://www.youtube.com/watch?v=eWoJ2YbdrWU&t=5s)构建一个 Rest api。这是我的games.php代码:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
use Illuminate\Database\Eloquent\Model;
class games extends Model implements AuthenticatableContract, AuthenticatableContract, HasRoleAndPermissionContract
{
use HasApiTokens, Authenticatable, Authorizable;
protected $table="games";
protected $fillable = ['Team 1','Team 2','Score 1','Score 2','Game Date','Viewers'];
}
我运行后得到的错误是:
PHP Fatal error: Trait 'App\HasApiTokens' not found in C:\Users...lumen-api\app\games.php on line 14
Fatal error: Trait 'App\HasApiTokens' not found in C:\Users\...lumen-api\app\games.php on line 14
In games.php line 14:
Trait 'App\HasApiTokens' not found
我所做的一切都与教程相同。我无法在第 2 部分中解决此错误。
【问题讨论】:
-
试试 "laravel/sanctum": "^2.6",