@rafaelgrube you need to nest the Condition A & Condition B so it checks both those conditions.
if I've got the nesting right, then this should be:
Model::select('id')
->whereIn('id', $Ids)
// Condition A (Since)
->where(function ($query) use ($date) {
$query
->where(function ($conditionA) use ($date) {
$conditionA->where('attribute_id', 24)
->where(function ($q) use ($date) {
$q->where('value', '<=', $date)->orWhereNull('value');
});
}) // Condition B (Until)
->where(function ($conditionB) use ($date) {
$conditionB->where('attribute_id', 25)
->where(function ($q) use ($date) {
$q->where('value', '>=', $date)->orWhereNull('value');
});
});
})
->groupBy('id')
->get()
->pluck('id');