public static function crear($input) { $respuesta = []; $reglas = ['tipo' => array('required'), 'diainicio' => array('required')]; $validador = Validator::make($input, $reglas); if ($validador->fails()) { $respuesta['mensaje'] = $validador; $respuesta['error'] = true; } else { $torneo = Torneo::where('nombre', '=', Input::get('tipo'))->where('codCampeonato', '=', Input::get('codcampeonato'))->first(); if ($torneo == '') { //recuperamos la fecha ingresada y lo acomodamos para ingresar a la base de datos $fecha = Input::get('diainicio'); $mes = substr($fecha, 0, 2); $dia = substr($fecha, 3, 2); $año = substr($fecha, 6, 4); $fecha = $año . '-' . $mes . '-' . $dia; //se crea un torneo $codCampeonato = Input::get('codcampeonato'); $users = DB::table('trueda')->count(); $users++; $users1 = (int) substr($codCampeonato, 3, strlen($codCampeonato)); $codconclusion = "TORO" . $users1 . $users; $input = Input::all(); $newtorneo = new Torneo(); $newtorneo->codRueda = $codconclusion; $newtorneo->nombre = Input::get('tipo'); $newtorneo->fechaCreacion = $fecha; $newtorneo->codCampeonato = $codCampeonato; $newtorneo->save(); $respuesta['mensaje'] = 'Datos guardados correctamente'; $respuesta['error'] = false; } else { $respuesta['mensaje'] = 'Este torneo ya existe'; $respuesta['error'] = true; } } return $respuesta; }
public function detail($codcampeonato, $idtorneo, $idfecha) { $torneo = Torneo::where('codRueda', '=', $idtorneo)->first(); $fecha = Fechas::where('idFecha', '=', $idfecha)->first(); $fixture = Fixture::where('nroFecha', '=', $fecha->nroFecha)->where('codRueda', '=', $idtorneo)->get(); $fixturedeequipoqueescansa = Fixtureaux::where('nroFecha', '=', $fecha->nroFecha)->where('codRueda', '=', $idtorneo)->first(); $equipoquedescansa = ''; // $todoConclusion = Cambio::all(); if ($fixturedeequipoqueescansa != '') { if ($fixturedeequipoqueescansa->codEquipo1 == '') { $equipoquedescansa = Equipo::where('codEquipo', '=', $fixturedeequipoqueescansa->codEquipo2)->first(); } else { $equipoquedescansa = Equipo::where('codEquipo', '=', $fixturedeequipoqueescansa->codEquipo1)->first(); } } return View::make('user_com_organizing.fecha.detail', compact('fecha'))->with('fixture', $fixture)->with('torneo', $torneo)->with('equipoquedescansa', $equipoquedescansa)->with('codcampeonato', $codcampeonato); }
public function partido($codcampeonato, $codrueda, $idfecha, $codpartido) { //$todoConclusion = Cambio::all(); //elementos $fecha = Fechas::find($idfecha); $partido = Partido::find($codpartido); $programacion = Programacion::find($partido->codProgramacion); $torneo = Torneo::where('codRueda', '=', $codrueda)->first(); $arbitros = Arbitro::all(); $arbixPart = ArbitroPorPartido::where('codPartido', '=', $codpartido)->count(); $todosArbitros = ArbitroPorPartido::where('codPartido', '=', $codpartido)->get(); //end elementos $nroPartido = $programacion->nroPartido; $fixture = Fixture::where('codRueda', '=', $torneo->codRueda)->where('nroFecha', '=', $fecha->nroFecha)->where('nroPartido', '=', $nroPartido)->first(); //elementos $equipo1 = Equipo::find($fixture->codEquipo1); $equipo2 = Equipo::find($fixture->codEquipo2); $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first(); $fechaactual = DB::select("select curdate() as fecha"); $fechasiguiente = DB::select("select adddate(curdate(),1) as fecha"); $fechaAnterior = DB::select("select subdate(curdate(),1) as fecha"); $hora = DB::select("select curtime() as hora"); $horaAsistencia = DB::select("select subtime(?,3000) as fecha", array($partido->horaInicio)); foreach ($fechaactual as $value) { $Factual = $value->fecha; } foreach ($fechasiguiente as $value) { $Fsiguiente = $value->fecha; } foreach ($hora as $value) { $horaA = $value->hora; } foreach ($fechaAnterior as $value) { $Fantes = $value->fecha; } foreach ($horaAsistencia as $value) { $HrAistencia = $value->fecha; } ///===== es la dia de programacion $HH = DB::select("select if(?=?,1,0) as fecha", array($fecha->diaFecha, $Factual)); foreach ($HH as $value) { $esdiaProgramacion = $value->fecha; } //end fechaf // mañena es dia de programacion $HH = DB::select("select if(?<?,1,0) as fecha", array($fecha->diaFecha, $Fsiguiente)); foreach ($HH as $value) { $manenaProgramacion = $value->fecha; } // ayer fue dia de programacion $HH = DB::select("select if(?=?,1,0) as fecha", array($fecha->diaFecha, $Fantes)); foreach ($HH as $value) { $ayerFProgramacion = $value->fecha; } // si la hora es mayor 23:50 $HH = DB::select("select if(?=?,1,0) as fecha", array(substr($horaA, 0, 5), "23:50")); foreach ($HH as $value) { $esHora = $value->fecha; } // es hora de inicio $HH = DB::select("select if(curtime()>=? and curtime()<?,1,0) as fecha", array($partido->horaInicio, "23:50:00")); foreach ($HH as $value) { $HoraI = $value->fecha; } //hora de tomo asistencia 30 min $HH = DB::select("select if(curtime()>=? and curtime()<=?,1,0) as fecha", array($HrAistencia, $partido->horaInicio)); foreach ($HH as $value) { $AH = $value->fecha; } $jugadoresequipo1 = ""; $jugadoresequipo2 = ""; $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first(); if ($activarPlanilla != "") { $Planilla1 = Planilla::where('codPartido', '=', $codpartido)->where('nroPlantilla', '=', 1)->first(); $Planilla2 = Planilla::where('codPartido', '=', $codpartido)->where('nroPlantilla', '=', 2)->first(); //$fixture->codEquipo1 //$Jequipo1 = Jugador::where('codequipo', '=', $fixture->equipo1)->get(); //$Jequipo2 = Jugador::where('codequipo', '=', $fixture->equipo2)->get(); //$arbitros = Arbitro::all(); //todos los jugadores de este partido $torneo $idtorneo,$idfecha,$idfixture) } /* $Delanteros1 = ''; $Mediocampistas1 = ''; $Defensas1 = ''; $Guardameta1 = ''; $suplentes1 = ''; $jugadoresdeunpartido2 = ''; //recuperamos los arbitros del partido $arbitrosdelpartido = ''; //verificamos si el partido ya se jugó //recuperar los datos del partido jugado $arbitrosdelpartido = ArbitroPorPartido::where('codPartido','=',$partido->codPartido)->first(); //resuperamos todos los jugadores de este partido ... un rato /* $Delanteros1 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente') ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo1) ->where('tjugadorenjuego.condicionenpartido','=','delantero') ->get(); $Mediocampistas1 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente') ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo1) ->where('tjugadorenjuego.condicionenpartido','=','mediocampista') ->get(); $Defensas1 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente') ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo1) ->where('tjugadorenjuego.condicionenpartido','=','defensa') ->get(); $Guardameta1 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente') ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo1) ->where('tjugadorenjuego.condicionenpartido','=','guardameta') ->get(); $suplentes1 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente') ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo1) ->where('tjugadorenjuego.condicionenpartido','=','suplente') ->get(); $jugadoresdeunpartido2 = DB::table('tjugadorenjuego') ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador') ->where('tjugadorenjuego.codpartido','=',$partido->codpartido) ->where('tjugador.codequipo','=',$fixture->equipo2) ->get(); */ $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first(); return View::make('user_com_organizing.fecha.partido.index', compact('fixture'))->with('idfecha', $idfecha)->with('torneo', $torneo)->with('programacion', $programacion)->with('codcampeonato', $codcampeonato)->with('arbitros', $arbitros)->with('partido', $partido)->with('arbixPart', $arbixPart)->with('todosArbitros', $todosArbitros)->with('equipo1', $equipo1)->with('equipo2', $equipo2)->with('activarPlanilla', $activarPlanilla)->with('esdiaProgramacion', $esdiaProgramacion)->with('manenaProgramacion', $manenaProgramacion)->with('ayerFProgramacion', $ayerFProgramacion)->with('esHora', $esHora)->with('HoraI', $HoraI)->with('AH', $AH); //->with('todoConclusion', $todoConclusion); }
public function detail($codcampeonato, $idtorneo) { //$tabla = DB::select('call TABLAPOSICIONES'); $fixture = Fixture::where('codRueda', '=', $idtorneo)->get(); $fechas = Fechas::where('codRueda', '=', $idtorneo)->get(); //$equipos = Equipoxtorneo::where('codRueda', '=', $idtorneo)->get(); $fechasdeltorneo = Fechas::where('codRueda', '=', $idtorneo)->get(); $campeonato = Campeonato::where('codCampeonato', '=', $codcampeonato)->first(); $torneo = Torneo::where('codRueda', '=', $idtorneo)->first(); $nroequipos = $this->nroequipos($codcampeonato); return View::make('user_com_organizing.torneo.detail', compact('fechasdeltorneo'))->with('codcampeonato', $codcampeonato)->with('torneo', $torneo)->with('nroequipos', $nroequipos); }