4
4
4sadly2021-12-13 18:18:42
Laravel
4sadly, 2021-12-13 18:18:42

How to build such a query using eloquent?

select * from `orders` where (exists (select * from `repairs` where orders.id = repairs.order_id and repairs.prepayment >= repairs.total * 0.5))

I try like this:
Order::whereHas('repairs' ,function ($query){
$query->where('repairs.prepayment', '>=', 'repairs.total * 0.5');
})->get();

$query->whereRaw('repairs.prepayment >= repairs.total * 0.5');  //так тоже пробовал

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mathrep, 2021-12-13
@4sadly

DB::raw() use

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question