laravel - Invisnik Laravel Steamauth 登录错误
问题描述
所以我刚刚在 laravel 7 中创建了一个项目并添加了invisnik steamauth,我还没有添加实际的 auth 包,所以这可能就是我遇到问题的原因,但是我不想失去什么我已经搞定了。
我运行了这个迁移:
Schema::create('users', function (Blueprint $table) {
$table->id("steamid");
$table->string('username');
$table->string('avatar');
$table->string('rank');
$table->rememberToken();
$table->timestamps();
});
然后我将 steamauth 控制器中的创建函数编辑为:
return User::create([
'username' => $info->personaname,
'avatar' => $info->avatarfull,
'steamid' => $info->steamID64,
'rank' => 0
]);
当我去登录时,我得到这个错误:
SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value (SQL: insert into `users` (`updated_at`, `created_at`) values (2020-05-06 18:32:42, 2020-05-06 18:32:42))
编辑:这是 User.php 模型
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
谢谢。
解决方案
推荐阅读
- python - 我应该在哪里继续让代码回到循环顶部?
- audio - 如何使用 FFMPEG 为 -SS 找到“安全”点以避免破坏 A/V 同步?
- docker - Docker 上的 Flask 应用程序,Windows 10 pro - OSError: [Errno 13] Permission denied
- javascript - 为什么我的输出数组不能正确自动排序(按字母顺序)?
- ruby-on-rails - Rails/Rspec - 如何在控制器测试中存根模型方法?
- sql - 为多供应商电子商务设计数据库产品和属性的最佳方法
- ios - 读取当前用户的数据?
- python - PIL img.resize 是否变大然后变小返回相同的图像?
- c# - 如何将 .sql 文件添加到 .MSI 项目文件?
- llvm - RTDyldMemoryManager::getSymbolAddressInProcess 在主机进程中找不到符号