jeudi 30 mars 2017

Laravel Eloquent: cherry pick custom attributes

I'm using an API to retrieve my objects in JSON. I have a model which has a lot of computing-intensive custom attributes (for example, sums from other tables in the database). On some pages, I'd like to load a specific set of custom attributes.

If they were relationships, I could use Model::with().

I'm looking for a way to "eager load" my custom attributes. For performance reasons, I don't want to add them to the model's $append list.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire