protected function buscarFechaDisponible() { //Obtengo la fecha y hora actual y le agrego un dia $fechaManana = Carbon::now()->addDay()->toDateString(); $horaActual = Carbon::now()->addHour()->format('H'); $now = Carbon::createFromFormat('Y-m-d H:i', $fechaManana . $horaActual . ":00"); $fechaDisponible = false; $fechaRevisar = $now; while (!$fechaDisponible) { if ($fechaRevisar->isWeekend() or !is_null(DiaInhabil::whereFecha($fechaRevisar->toDateString())->first())) { $fechaRevisar = $fechaRevisar->addDay(); } else { if ($this->esFechaValida($fechaRevisar)) { $fechaDisponible = true; } else { $fechaRevisar = $fechaRevisar->addHour(); } } } return $fechaRevisar->toDateTimeString(); }
protected function esDiaInhabil($fecha) { $fechaInhabil = DiaInhabil::whereFecha($fecha)->first(); if (is_null($fechaInhabil)) { return false; } else { return true; } }