Ejemplo n.º 1
0
 /**
  * Genera el torneo y los partidos para imprimir el fixture de la fecha.
  *
  * @param  int  $id torneo id
  * @return \Illuminate\Http\Response
  */
 public function posiciones_pdf(Request $request)
 {
     $torneo_id = $request->get('torneo_id');
     $torneo = Torneo::with('temporada')->with('division.categoria.genero')->with('fases.grupos.clubes.torneo_club.club')->with('fechas.partidos.clubes.torneo_grupo_club.torneo_grupo.fase')->with('fechas.partidos.clubes.torneo_grupo_club.torneo_club.club')->with('clubes.club')->findOrFail($torneo_id);
     $this->data = array_merge(['torneo' => $torneo, 'temporada' => $torneo->temporada, 'division' => $torneo->division, 'categoria' => $torneo->division->categoria, 'clubes' => $torneo->clubes, 'fases' => $torneo->fases->sortBy('orden')], $this->data);
     /*
             $fecha = TorneoFecha::with('torneo')->findOrFail($fecha_id);
             $partidos = Partido::with('fecha')->with('estadio')->where('fecha_id', $fecha_id)->get();
     
             $this->data = array_merge([ 'torneo' => $fecha->torneo, 'partidos' => $partidos , 'fecha' => $fecha->orden ]);
     */
     $pdf = \PDF::loadView('admin.pdf.posiciones', $this->data);
     return $pdf->stream('goleadores.pdf');
 }
Ejemplo n.º 2
0
 public function SeedPlantillas()
 {
     DB::transaction(function () {
         $socios = Socio::all();
         $socios_cant = $socios->count();
         $socios_temporada_cant = 0;
         $torneo = Torneo::with('temporada')->with('division.categoria.genero')->with('fases.grupos.clubes.torneo_club.club')->with('fechas.partidos.clubes.torneo_grupo_club.torneo_grupo.fase')->with('fechas.partidos.clubes.torneo_grupo_club.torneo_club.club')->with('clubes.jugadores')->with('clubes.club')->findOrFail(1);
         $cant_jugadores = 20;
         $torneo_clubes = $torneo->clubes;
         foreach ($torneo_clubes as $torneo_club) {
             for ($i = 0; $i < $cant_jugadores and $socios_temporada_cant < $socios_cant; $i++) {
                 $encontre = 0;
                 while (!$encontre) {
                     $socio = $socios->random();
                     $encontre = !$socio->participoEnTorneo($torneo->id);
                 }
                 $trayectoria = new Trayectoria();
                 $trayectoria->socio_id = $socio->id;
                 $trayectoria->club_id = $torneo_club->club->id;
                 $trayectoria->save();
                 $temporada_plantel = new TemporadaPlantel();
                 $temporada_plantel->jugador_id = $socio->id;
                 $temporada_plantel->temporada_id = $torneo_club->torneo->temporada->id;
                 $temporada_plantel->save();
                 $torneo_plantel = new TorneoPlantel();
                 $torneo_plantel->jugador_id = $temporada_plantel->id;
                 $torneo_plantel->torneo_club_id = $torneo_club->id;
                 $torneo_plantel->save();
                 /*DB::table('trayectorias')->insert(array(
                                         array (
                                             "socio_id"  => $socio->id,
                                             "club_id"   => $torneo_club->club->id,
                                         ),
                                     ));
                 
                                     DB::table('temporadas_planteles')->insert(array(
                                         array (
                                             "id"            => $temporadas_plantel_id,
                                             "jugador_id"    => $socio_id,
                                             "temporada_id"  => 1,
                                         )
                                     ));
                 
                                     DB::table('torneos_planteles')->insert(array(
                                         array (
                                             "id" => $torneos_plantele_id,
                                             "jugador_id" => $temporadas_plantel_id,
                                             "torneo_club_id" => $club_torneo,
                                         )
                                     ));*/
             }
         }
     });
 }