首页 > 解决方案 > 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',
    ];
}

谢谢。

标签: laravelsteam

解决方案


推荐阅读