User Avatar: Store URL or generate

Posted 11 months 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.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.