I have leaves table which has employee_id, leave_type_id, from_date , to_date etc.
I also have a form that captures the from_date and to_date , so i wanted to do a check that if an employee applies for a leave that has its from_date and to_date between the from_date and to_date existing in the database to have the application declined.
this is what i have tried so far but it is not accurate:
$leave_exists = Leave::where('employee_id',$request->employee_id)
->whereBetween(DB::raw('from_date AND to_date'), [$request->from_date, $request->to_date])
->get();