Support the ongoing development of →
Database Eloquent
Last updated 1 year ago.

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.

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.