public function add($idcampeonato, $idtorneo) { $input = Input::all(); $rules = array('fecha' => 'required', 'horainicio' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator); } else { $nrofecha = Input::get('nrofecha'); //recuperamos la fecha ingresada y lo acomodamos para ingresar a la base de datos $fecha = Input::get('fecha'); /* $mes = substr($fecha,0,2); $dia = substr($fecha,3,2); $año = substr($fecha,6,4); $fecha = $año.'-'.$mes.'-'.$dia; */ $horaincio = Input::get('horainicio'); $lugar = input::get('lugar'); $hora = substr($horaincio, 0, 2); $min = substr($horaincio, 3, 2); $horaI = (int) $hora; $minI = (int) $min; $fixturefecha = Fixture::where('nroFecha', '=', $nrofecha)->where('codRueda', '=', $idtorneo)->get(); $i = 1; $siguiente = $horaI . ":" . $minI; foreach ($fixturefecha as $value) { $value->hora = $siguiente; $value->nropartido = $i; $value->save(); $mas = 0; $minI = $minI + 30; if ($minI >= 60) { $mas = 1; $minI = $minI % 60; } $horaI = $horaI + 1 + $mas; $siguiente = $horaI . ":" . $minI; $i++; } $category = new Fechas(); $users = DB::table('tfecha')->count(); $users++; $users1 = substr($idtorneo, 3, strlen($idtorneo)); $codasistente = (int) $users1 . $users; $category->idFecha = $codasistente; $category->nroFecha = $nrofecha; $category->diaFecha = $fecha; $category->codRueda = $idtorneo; $category->save(); return Redirect::to('fecha/edit/' . $idcampeonato . '/' . $idtorneo . '/' . $nrofecha); } }