1
我试图把计数约束laravel雄辩的嵌套关系,但它没有按预期工作。计数约束不工作laravel雄辩嵌套关系
这里的情况是:取酒店那些有客房,日期范围内都可以
$hotels = Hotel::where('destination_id', $destinationId) - > with(['rooms' = > function ($query) use($totalNights, $check_in, $check_out) { $query - > with([ 'dateWisePricing' = > function ($dateWisePricing) use($check_in, $check_out) { $dateWisePricing - > where('date', '>=', $check_in); $dateWisePricing - > where('date', '<', $check_out); $dateWisePricing - > orderBy('date'); } ]); $query - > has('dateWisePricing', '>=', $totalNights); } ]) - > has('rooms.dateWisePricing') - > get();
这里它返回的客房,是在该日期范围avuable(即dateWisepricing IM空集)
任何请帮助
dayWisePricing是在房间的关系不是酒店的 – kamalakar
是的,我已经重新编辑我进入 –
请你解释一下它是如何从我前面的代码不同,因为它返回相同的结果和约束,也没有工作,因为它 – kamalakar