I am doing a query eloquent
to fetch the data that is on one date or another, I am doing it as follows:
$eneP= tbl_calibracion::where('cal_usu_id',$onlyId)
->whereDate('cal_proximaCalibracion','=','2019-01-01 00:00:00')
->orWhere('cal_proximaCalibracion','=','2020-01-01 00:00:00')
->count();
The problem is that it brings me 34 records when it should bring 4, I made the query in mysql
and it worked for me like this:
SELECT count(cal_id)as id FROM `tbl_calibracion` WHERE cal_usu_id='7' and (cal_proximaCalibracion='2019-01-01 00:00:00' or cal_proximaCalibracion='2020-01-01 00:00:00')
In MySQL
I got 34 records if I didn't put the parentheses but error
how can I solve that with eloquent?
You must use a where with function to generate the parentheses