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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire