In this episode, we're getting our Laravel User model prepped so it can handle profile photos. We'll start off with a fresh project (Laravel Breeze with Livewire and Volt, but you can pick your own setup) and create a database migration to add a profile_photo_url
field to the users table. Super simple—just a nullable string field.
Instead of packing all the profile photo logic into the User model, we're making a separate trait (HasProfilePhoto
) in the app/Models/Traits
directory. This makes things reusable in case, for example, you later want teams to have profile photos too.
Inside the trait, we set up:
Finally, we do a quick and dirty test by dumping the profile photo URL for the current user in a route, just to check it's all working. That's it for this setup—next steps will handle uploading and actually displaying profile photos.