Search code examples
phplaraveloauth-2.0laravel-socialite

how can I get original avatar with socialite in laravel?


I work with socialite in laravel 5.6

with this

$social_user = Socialite::driver($provider)->user();

and with dd($social_user)

results:

User {#799 ▼
  +token: "517439085-SQzlrx8Op"
  +tokenSecret: "8KnMz1K5WQ9lpg"
  +id: "5176085"
  +nickname: "test"
  +name: "test"
  +email: "test@outlook.com"
  +avatar: "http://pbs.twimg.com/profilermal.jpeg"
  +user: array:40 [▶]
  +"avatar_original": "http://pbs.twimg.com/profileyxeYC5.jpeg"
}

I could get name, id and...

 $social_user->getName();
 $social_user->getAvatar();
 $social_user->getId();

But how can I get avatar_original?


Solution

  • Since the avatar and other properties are public, you can just access them using the standard syntax:

    $social_user->avatar;