社会名流函数 getId() 正在运行,但 id 未添加到数据库 phpmyadmin

Socialite function getId() is working but id is not added in database phpmyadmin

我正在使用 Laravel Socialite 登录 google 所有 scoialite 功能都工作正常并且数据正在添加到数据库 (phpmyadmin) 除了 provider_id 哪个功能是getId() 也可以正常工作,但数据未插入 Db。

public function handleProviderCallback()
    {

        try{
            $socialUser = Socialite::driver('google')->user();

        }catch(Exception $e){
            redirect('/');

        }
        $socialProvider = SocialProvider::where('provider_id', $socialUser->getId())->first();
        if(!$socialProvider){
            //create new user
            $user = User::firstOrCreate(
                ['email' => $socialUser->getEmail()],
                ['name' => $socialUser->getName()]

            );


            $user->socialProviders()->create(
                ['provider_id' => $socialUser->getId() , 'provider' => 'google']
            );
        }
        else{

            $user = $socialProvider->user;
        }

        auth()->login($user);
         return redirect('/home');
        //return $socialUser->getId();
    }

'provider_id' 必须是 SocialProvider 模型上的 protected $fillable 数组,如果你想在数组中将它传递给 SocialProvider->create(...).