According to your description, I do not quite understand what you want to do)). I think you need casts something like this:
$query->whereHas('avaibleDates', function($q) {
$q->where(function ($q) {
$q->where('start_date', '<=', 2)->where('status_id', '!=', 2);
});
// The following conditions
...
$q->orWhere(function ($q) {
$q->where('start_date', '>', 55)->where('status_id', '!=', 7);
});
...
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…