Use the $appends attribute.
http://laravel.com/docs/eloquent#converting-to-arrays-or-json
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!
The Laravel portal for problem solving, knowledge sharing and community building.
The community