已升级到 Laravel 7 并已安装 Laravel/Airlock。
如果尝试创建令牌,请按照安装说明进行操作,但出现错误
SQLSTATE [23000]:完整性约束违规:1048列'tokenable_id'不能为空(SQL:插入
personal_access_tokens
(name
,,,,,,,,)值( api-tokentoken
, 31afd4da089878bd2cd562264bd2d8c789c7a1f91e47f6corder3969bce2fc19a7329abilities
,[ “ "WLR3:check_availability"], ?, App\Models\User, 2020-03-06 10:44:05, 2020-03-06 10:44:05))tokenable_id
tokenable_type
updated_at
created_at
在我的 TokenController.php 我有:
public function create(User $user, Request $request)
{
$token_name = $request->input('token_name', 'api-token');
$abilities = $request->input('abilities', [
'order:create',
'order:view',
'WLR3:check_availability'
]);
$token = $user->createToken($token_name, $abilities);
return $this->view($user, $request);
}
我错过了什么可能导致此错误?
在用户模型上,它以:
use Laravel\Airlock\HasApiTokens;
class User extends Authenticatable /* implements MustVerifyEmail */
{
use HasRoles, HasApiTokens, Notifiable;
protected $guard_name = 'web';