/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['team_1_score' => 'required', 'team_2_score' => 'required']);
     $fixture = Fixture::find($id);
     $fixture->team_1_score = $request->get('team_1_score');
     $fixture->team_2_score = $request->get('team_2_score');
     $fixture->save();
     flash()->success('', 'Rezultatas redaguotas!');
     return redirect()->back();
 }
Esempio n. 2
0
 /**
  * Show the application home (predict) page to the user
  * 
  * @return Response
  */
 public function index()
 {
     $user = \Auth::user();
     $gws = \App\Gameweek::incomplete()->take(2)->with('fixtures')->with(['fixtures.predictions' => function ($query) use($user) {
         $query->where('user_id', $user->id);
     }])->get();
     foreach ($gws as $gw) {
         $userGameweek = $user->gameweeks()->where('gameweek_id', $gw->id)->first();
         $boostId = null;
         $boostedClosed = false;
         if ($userGameweek) {
             $boostId = $userGameweek->pivot->boost_id;
             if ($boostId) {
                 $boostedClosed = \App\Fixture::find($boostId)->isClosed();
             }
         }
         $gw->boostId = $boostId;
         $gw->boostedClosed = $boostedClosed;
     }
     $nameOfPage = 'home';
     return view('pages.home', compact('gws', 'user', 'nameOfPage'));
 }