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