Mysql
 sql >> Database >  >> RDS >> Mysql

Laravel tra con o tra

Dovresti avvolgere whereBetween &orWhereBetween in where. Prova questo:

$childs = Program::whereIn('id', $programs_by_date)
            ->where('shareable', '=','1')
            ->where(function($query) use ($new_start_date, $new_end_date){
                  $query->whereBetween('starting_date', [$new_start_date,$new_end_date])
                        ->orWhereBetween('ending_date', [$new_start_date,$new_end_date]);
                })
            ->orderBy('starting_date')
            ->get();

Spero che funzioni.