I have 3 model Transaction , Cart , Acceptedcart.
in Cart model I have transaction_id and in Acceptedcart model have cart_id.
how can I find transactions where acceptedcart->delivered == true ?
can I write that like this ?
$transactions = Transaction::whereIn('id',function ($query) {
return Cart::whereIn('id' , function($subquery){
return AcceptedCart::where('delivered' , false)->pluck('cart_id');
})->pluck('transaction_id');
})->get();
or :
$transactions = Transaction::whereIn('id' , function($query){
$query->select('transaction_id')->from('carts')->whereIn('id' , function($subquery){
$subquery->select('cart_id')->from('accepted_carts')->where('delivered' , true);
});
})->get();
thanks.