1 week ago

What would be the best way to handle a Model column that is derived from another one

Posted 1 week ago by catalin8

On a particular model I have a

title ( text ) column and another

normalized_title a sort of slug derived from the title column

Being fairly new to Laravel and seeing how most of the learning tutorials are straight forward and super clean I wanted to ask if there is any particular way to handle such a column in a "automated" way.

On one hand I was thinking to set up an observer and simply modify the normalized_title whenever the title column is updated or created.

But this would probably cost at least an extra update operation, and that's not what I'm looking for.

So, is there any way to achieve this ?

Thank you!

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