温馨提示:本文翻译自stackoverflow.com,查看原文请点击:Laravel 6 steam auth - How to store?
laravel laravel-6

Laravel 6 steam auth - 如何储存?

发布于 2020-04-07 10:56:08

我想使用此软件包获取用户信息:https : //github.com/invisnik/laravel-steam-auth 但是我对laravel atm完全不了解。

如何将SteamID64存储在名为“ steamid”的Auth :: user()字段中

我以下的处理atm:

public function handle()
    {
        if ($this->steam->validate()) {
            $info = $this->steam->getSteamId();

            if (!is_null($info)) {
                //I should store the steamid64 inside the Auth::user() field named 'steamid'
                return redirect($this->redirectURL); // redirect to site
            }
        }
        return $this->redirectToSteam();
    }

我希望有人可以指引我正确的方向。提前致谢

查看更多

提问者
Kh4zy
被浏览
14
N69S 2020-02-01 17:53

您可以使用save()

Auth::user()->steamid = $info;
Auth::user()->save();

或使用 update()

Auth::user()->update(['steamid' => $info]);

要检查Steamid是否已存在于数据库中:

$isAlreadyPresent = User::where('id', '!=', Auth::id())->where('steamid', '=', $info)->count();

如果$isAlreadyPresent为零,则您的数据库中没有SteamID,或者它是当前用户SteamID。