samedi 28 mai 2016

Eager-loading only some of the properties

I have two models: Question and Answer. A question has-many answers. To eager-load a question's answers, one must write it like this:

$question->load('answers');

However, all of the answers' properties are loaded this way. The following code, while illustrating what I want to achieve, does not work:

$quesiton->load('answers')->select('id', 'body')

So, how can I eager-load questions' answers with only their respective id, and body properties?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1sUJbJW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire