F
Filament6mo ago
ericmp

Creating spatie media library collections dynamically

Till now, a user only had one profile pic. But now, for each season (for example on september we start a new season), users have to upload a different profile pic. I have a Season model, where seasons name, start and end at fields are stored. Currenty, the user pic is stored in a spatie medialibrary collection - 'profilePicture' So my question is how to handle this with spatie medialibrary? I was thinking of creating dynamic spatie medialib collections: 'profilePictureSeason1' (where 1 is the id of the season) 'profilePictureSeason2' etc then, everywhere i need to retrieve the user profile pic ill just use this fn (pseudocode): getProfilePic(seasonid) return $this->getFirstMediaUrl("profilePicture{$seasonId}") What do u think? U think its fine like this or u'd do it different?
3 Replies
ericmp
ericmpOP6mo ago
bump bump
toeknee
toeknee6mo ago
You can absolutely do it that way. Or you can add custom fields to 'seasion:2' for example for uploading them anyway.
ericmp
ericmpOP6mo ago
oh i see hmm. thanks for the feedback. apreciate it
Want results from more Discord servers?
Add your server