Laravel 6 steam auth - 如何存储?
Laravel 6 steam auth - How to store?
我正在尝试使用此包获取用户信息: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。
我正在尝试使用此包获取用户信息: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。