mercredi 2 octobre 2019

Filtering the records using eloquent, laravel

I am try to get a records from the database as filter using this query

$this->subscriptions = Subscription::with([
    'fulfillment.shipments'
])
->where(function($query) use ($shipmentBatchId) {
    $query->whereHas('fulfillment.shipments', function($query) use ($shipmentBatchId) {
        $query->where('shipment_batch_id', $shipmentBatchId);
    });
})
->latest()
->limit(100)
->skip($skip)
->get();

This result php stop the execution due to large result

I don't know if the query above has similar idea with this

SELECT subscriptions.id FROM subscriptions 
JOIN fulfillments on fulfillments.subscription_id=subscriptions.id
JOIN shipments ON shipments.fulfillment_id=fulfillments.id
where shipment_batch_id=13

What is the proper way way of doing it in eloquent given the above query?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire