mardi 29 août 2017

how do I order eager relationship using with()

I need to order

Content::with('blocks.settings')->where('slug', $slug)->first();

blocks by a 'order' column, how can I do that?

i am aware of this approach:

with(array('model' => function($query) {
        $query->orderBy('result', 'DESC');
    }))

but I am not sure how that would work in my case? I am using nested eager loading and it seems to me that above approach will only work for single level eager load?

Can someone give me an idea how to solve this?



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

Aucun commentaire:

Enregistrer un commentaire