Código:
public function validarFecha($fecha, $horaInicial, $horaFinal)
{
$agenda = Booking::select("*")
->whereDate('day', $fecha)
->whereBetween('hour_start', [$horaInicial, $horaFinal])
->orWhereBetween('hour_end', [$horaInicial, $horaFinal])
->first();
return $agenda === null || $agenda->hour_end === $horaInicial
}
-----------------------------
public function store(Request $request)
{
$input = $request->all();
if($this->validarFecha($input["txtFechaInicio"], $input["txtHoraInicio"], $input["txtHoraFinal"])){
$agenda = Booking::create([
"id_user"=>$input["ddlUsuarios"],
"day"=>$input["txtFechaInicio"],
"hour_start"=>$input["txtHoraInicio"],
"hour_end"=>$input["txtHoraFinal"],
"observation"=>$input["txtDescripcion"]
]);
return response()->json(["ok"=>true]);
}else{
return response()->json(["ok"=>false]);
}
dd($input);
}


