I'm trying to get all Projects where status is Not active and Vendor balance for that project is Not 0.
The below gets me all Projects where status is Not active and (Vendor) Bid for that project is Not 0. It seems I need to replace where('amount' , '!=', 0) with something else but I can't seem to figure it out as there is a lot of variables.
$balances = Project::whereHas('bids', function ($query) use ($vendor){
$query->where('amount' , '!=', 0)->where('vendor_id', $vendor->id);
})->with(['bids' => function ($query) { // use ($vendor)
$query->get()->where('latestStatus.title_id', '!=', 5);
}])->get();
To get the Vendor Balance for a projects I need to sum all Expenses for the vendor for each Project and subtract that from the Bid('amount'). Everything is on separate tables and I can elaborate as well.
Any any help is appreciated. Writing here and thinking through my issue really helps and everyone is really helpful.
Thanks! Patryk
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire