User Avatar: Store URL or generate

Posted 1 year ago by packy

I was in a discussion with @arthurvillar about adding avatar field to the user database. He mentioned he doesn't store the url path but generates it:

"Well, if you can make a unique filename based on the user's name (or a username) why would you add another column for that? On the model you can add a getAvatarAttribute (or even just a simple function) and create a simple logic to have that name included in your object without having to worry about it in creating, updating, validating, etc."

I always stored the full url path to my Spaces bucket in avatar field on the user table. Is there any benefit to using one way or the other? Or a best practice?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.