Use the $appends attribute.
See the link and scroll down up to the bottom page to see how it works.
Basically, what this thing does is it creates a custom attribute to your model. You will create a getter for that attribute and put the logic there. Then in your view, you can just fetch the attribute.
Other answers other than this is welcome. I'm also interested if there are other ways to do it besides this.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us