Пример #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $torneo = Torneo::findOrFail($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.jugadores')
       ->with('clubes.club')
       ->findOrFail($id);*/
     $this->webpage['whereAmI'] = $this->BreadcrumbRoot($torneo->temporada, $torneo);
     $this->webpage['whereAmI'] .= $this->listOneBreadcrumb('editar');
     $this->webpage['tab_title'] = $torneo->maximal_full_name . ' - Editar';
     $equipos = Club::with(['divisiones' => function ($q) use($torneo) {
         $q->where("division_id", $torneo->division);
     }])->get();
     $tipo_primera_fase = TipoTorneoFase::where('fase_numero', 1)->where('tipo_torneo_id', $torneo->tipo_torneo_id)->first();
     $torneo_clubes = TorneoClub::with(['club', 'torneo_grupos'])->whereHas('torneo_grupos', function ($q = '') {
         $q->whereHas('torneo_grupo', function ($subq) {
             $subq->where("fase_id", 1);
         });
     })->where("torneo_id", $torneo->id)->get();
     // OJO; DIF ENTRE EQUIPOS Y TORNEOS CLUBES, VERIFICAR
     $equipos = $equipos->diff($torneo_clubes->pluck('club'));
     // dd($equipos);
     /*$partidos = Partido::with('fecha')->whereHas('fecha',function ($q) use ($id) {
                     $q->where('torneo_id',$id);
                 })->whereIn('estado_id',[3,4,5,6])->get();
     
                 $torneo->comenzado = false;
                 if ($partidos->count()) {
                     $torneo->comenzado = true;
                 }*/
     $this->data = array_merge(['webpage' => $this->webpage, 'equipos' => $equipos, 'torneo_clubes' => $torneo_clubes, 'torneo' => $torneo, 'tipo_primera_fase' => $tipo_primera_fase], $this->data);
     return view('admin.seasons.torneos.edit', $this->data);
 }
Пример #2
0
 /**
  * Can a user edit the current club
  *
  * @return boolean
  */
 public function canEdit($club)
 {
     $editor = Club::with('users')->find($club->id)->users->toArray();
     return in_array($this->id, array_flatten($editor));
 }
Пример #3
0
 public function search_in_plantilla()
 {
     $result = array();
     //DB::enableQueryLog();
     $search_text = Input::get("text");
     $club_id = Input::get("club_id");
     $club = Club::with('jugadores')->where("id", $club_id)->first();
     $plantilla = $club->jugadores;
     $socios = Socio::with(['persona', 'persona.tipo_documento'])->whereHas('persona', function ($q) use($search_text) {
         $q->where("documento", 'LIKE', '%' . $search_text . '%')->orWhere("apellido", 'LIKE', '%' . $search_text . '%')->orWhere("nombre", 'LIKE', '%' . $search_text . '%');
     })->orWhere("carnet", 'LIKE', '%' . $search_text . '%')->get();
     $delegados = $plantilla->pluck('socio_id');
     $socios_ids = $socios->pluck('id');
     $delegados_filtered_ids = $delegados->intersect($socios_ids)->toArray();
     //dd($socios_ids);
     $delegados = $socios->whereIn("id", $delegados_filtered_ids);
     foreach ($delegados as $socio) {
         $socio->persona->full_name = $socio->persona->full_name;
         $socio->persona->inverse_full_name = $socio->persona->inverse_full_name;
         $result[] = $socio;
     }
     //dd(DB::getQueryLog());
     return response()->json(['result' => 'Ok', 'response' => $result]);
 }