首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel 6 steam auth -如何存储?

Laravel 6 steam auth -如何存储?
EN

Stack Overflow用户
提问于 2020-01-31 23:52:01
回答 1查看 75关注 0票数 0

我正在尝试用这个包抓取用户信息:https://github.com/invisnik/laravel-steam-auth,但我完全是laravel atm的新手。

如何在名为'steamid‘的Auth::steamID64 ()字段中存储用户

我的以下处理自动柜员机:

代码语言:javascript
复制
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();
    }

我希望有人能给我指引正确的方向。提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-01 17:53:21

您可以使用save()完成此操作

代码语言:javascript
复制
Auth::user()->steamid = $info;
Auth::user()->save();

或者使用update()

代码语言:javascript
复制
Auth::user()->update(['steamid' => $info]);

要检查数据库中是否已存在steamid,请执行以下操作:

代码语言:javascript
复制
$isAlreadyPresent = User::where('id', '!=', Auth::id())->where('steamid', '=', $info)->count();

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60007205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档