我想使用此软件包获取用户信息: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。
谢谢你,先生 :)