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
ericmp6d ago
bump bump
toeknee
toeknee6d ago
You can absolutely do it that way. Or you can add custom fields to 'seasion:2' for example for uploading them anyway.
ericmp
ericmp6d ago
oh i see hmm. thanks for the feedback. apreciate it
Want results from more Discord servers?
Add your server
More Posts