Exemplo n.º 1
0
 /**
  * Adds a new member to the Club
  */
 public function storeMember(Request $request)
 {
     $this->setRequestValidator(new \App\Http\Requests\StoreClubMemberRequest());
     $this->validateRequest($request);
     $club = \App\Club::find($request->input('club_id'));
     $member = \App\User::find($request->input('user_id'));
     $club->members()->attach($member->id);
     return \Fractal::collection($club->members, new \App\Transformers\UserTransformer())->getArray();
 }
Exemplo n.º 2
0
 /**
  * Store the created club
  *
  * @param  ClubRequest $request [description]
  * @return redirect to the created club
  */
 public function store(Request $request)
 {
     $validator = $this->validate($request, ['name' => 'required|unique:clubs|alpha_dash|max:30']);
     $club = new Club();
     $club->name = $request->name;
     $club->slug = strtolower($request->name);
     $club->description = $request->description;
     $club->save();
     $pivotClub = Club::find($club->id);
     $pivotClub->users()->attach($this->user->id);
     flash()->overlay('Club created!', 'Now start uploading images!');
     return redirect("clubs/{$club->slug}");
 }
Exemplo n.º 3
0
 public function edit(Request $request, $id)
 {
     $review = Screv::find($id);
     if ($review->user_id == $request->user()->id) {
         if ($review->model == 0) {
             $model = Sc::find($review->model_id, ['name']);
         } else {
             $model = Club::find($review->model_id, ['name']);
         }
         return view('screv.edit', ['review' => $review, 'model' => $model]);
     } else {
         return redirect()->back();
     }
 }
Exemplo n.º 4
0
 public function versions($id)
 {
     $club = Club::find($id, ['id', 'name']);
     $versions = Clubver::with(['user' => function ($query) {
         $query->select('id', 'name');
     }])->select('user_id', 'first', 'name', 'information', 'created_at', 'updated_at')->where('club_id', $id)->orderBy('updated_at', 'desc')->get();
     return view('club.versions', ['club' => $club, 'versions' => $versions]);
 }
Exemplo n.º 5
0
 public function getStats($season)
 {
     $pairs = $this->pairs()->where('season_id', '=', $season->id)->get();
     foreach ($pairs as $pair) {
         $matches = array();
         $firstMatches = $pair->firstMatches()->get();
         foreach ($firstMatches as $match) {
             $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 0];
             array_push($matches, $dataMatch);
         }
         $secondMatches = $pair->secondMatches()->get();
         foreach ($secondMatches as $match) {
             $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 1];
             array_push($matches, $dataMatch);
         }
         $pair['ref1'] = Person::find($pair->ref1_id);
         $pair['ref2'] = Person::find($pair->ref2_id);
         $pair['countFall'] = count($firstMatches);
         $pair['countSpring'] = count($secondMatches);
         $pair['matches'] = $matches;
     }
     $courts = $this->referees()->wherePivot('type', '=', 1)->wherePivot('season_id', '=', $season->id)->get();
     foreach ($courts as $court) {
         $matches = array();
         $firstMatches = $court->firstMatchesAsCourt()->get();
         foreach ($firstMatches as $match) {
             $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 0];
             array_push($matches, $dataMatch);
         }
         $secondMatches = $court->secondMatchesAsCourt()->get();
         foreach ($secondMatches as $match) {
             $dataMatch = ['id' => $match->id, 'home' => Club::find($match->home_id)->name, 'away' => Club::find($match->away_id)->name, 'round_id' => $match->round_id, 'type' => 1];
             array_push($matches, $dataMatch);
         }
         $court['countFall'] = count($firstMatches);
         $court['countSpring'] = count($secondMatches);
         $court['matches'] = $matches;
     }
     $response = array('pairs' => $pairs, 'courts' => $courts);
     return $response;
 }