jeudi 27 juin 2019

Laravel With() relation querying - condition to main table

I need to query a nested relation using 'with' construction, but I have no idea how to use main table's fields in relation condition. Example:

Order::with([
    'products',
    'statuses' => function($statuses) {
        $statuses->where('id', LAST_STATUS_ID_FROM_ORDERS_TABLE);
    }
])->get()

Any suggestions?



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

Aucun commentaire:

Enregistrer un commentaire