laravel - Laravel 6 steam auth - 如何存储?
问题描述
我试图用这个包获取用户信息: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();
}
我希望有人能引导我朝着正确的方向前进。提前致谢
解决方案
您可以使用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。
推荐阅读
- regex - 排除部分正则表达式选择
- laravel - laravel 中的 Vue.js
- python - app_label 的目的是什么
- python - 将两个 pygame.Color 对象混合在一起
- android - 用 diffUtils 更新列表的最佳方法是什么
- ubuntu - 在 UBUNTU 16.04 上安装 jenkins 时遇到错误列表
- java - 如何修复“关系”
不存在”错误,即使使用 'IF EXISTS-THEN' pgsql 块? - python - 通过正则表达式获取两个模式之间的所有行
- batch-file - 如何将数千个图像文件移动到每个包含 400 个图像文件的子文件夹中?
- android - 为 IntentServices 定义意图的最简洁方法?