我想使用 spatie 来获取 Google+ 头像,但是当我尝试获取它时出现错误。
$user = Socialite::driver('google')->user();
$usertest=User::whereEmail($user->getemail())->first();
if(! $usertest){
$usertest=User::create([
'name'=>$user->name,
'email'=>$user->email,
'password'=>bcrypt($user->id)
]);}
$usertest->addMediaFromUrl($user->avatar)->toMediaCollection('avatar');
auth()->loginUsingId($usertest->id);
return redirect('/');
错误:
类型错误:传递给 Spatie\MediaLibrary\FileAdder\FileAdder::processMediaItem() 的参数 1 必须是 Spatie\MediaLibrary\HasMedia\HasMedia 的实例,给定 App\User 的实例,