Get accessor attribute within collection

Medienopfer98 posted 1 year ago

Hi. I have a collection from a model and there is an extra attribute to generate the url for this element. In laravel blade everything works when i call:


But i use vuejs and send all companies at once into vue component. I can access there everything from my normal $company. Like the title, description, ... but not the new attribute i defined in model with public function getAppLinkAttribute(). Hope somebody can help. thx.

lagbox replied 1 year ago

You need to read the section on Eloquent Serialization. It explains how to add accessors to the output. Good luck :)

Sign in to participate in this thread!

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