Skip to content
Advertisement

Laravel 8 Jetstream Profile Photos with Socialite Avatars

I’m trying Laravel 8 Jetstream with Laravel Socialite. The problem is when I retrieve the avatar and use its URL to profile_photo_path. The blade file appends http://localhost:8000/storage/ that is causing the avatar not to display. screenshot here

I have enabled jetstream’s profile photos on config/jetstream.php

JavaScript

Here’s how I store the user app/Http/Controllers/LoginController.php

JavaScript

I saw the problem here resources/views/navigation-menu.blade.php

JavaScript

So I tried to remedy this blade file and put an if statement here :

JavaScript

The ‘If statement’ is flawed, it would break when socialite logged-in users decided to change their picture. I tried this solution but it only stores numeric value to my profile_photo_path. Any idea how to make socialite and Jetstream’s built-in profile photos work?

Advertisement

Answer

I copied getProfilePhotoUrlAtrribute method from vendor/laravel/jetstream/src/HasProfilePhoto.php to AppModelsUser and modified it to accept avatar url from social site or retrieve uploaded photo.

JavaScript

Jetsream docs reference

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement