コード例 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  *
  * @return mixed
  */
 public function edit($id)
 {
     $availableAppointment = AvailableAppointment::findOrFail($id);
     $fixtures = Fixture::all();
     $roles = Role::all();
     return view('admin.data-management.available-appointments.edit', compact('availableAppointment', 'fixtures', 'roles'));
 }
コード例 #2
0
ファイル: TeamsTableTest.php プロジェクト: troccoli/lva
 public function testDeleteTeam()
 {
     $this->be($this->getFakeUser());
     /** @var Team $team */
     $team = factory(Team::class)->create();
     $teamId = $team->id;
     $this->seeInDatabase('teams', ['id' => $team->id, 'club_id' => $team->club_id, 'team' => $team->team])->makeRequest('DELETE', route(self::BASE_ROUTE . '.destroy', [$team->id]))->seePageIs(route(self::BASE_ROUTE . '.index'))->seeInElement('#flash-notification .alert.alert-success', 'Team deleted!')->dontSeeInDatabase('teams', ['id' => $teamId]);
     // Delete team with fixtures
     /** @var Team $team */
     $team = factory(Team::class)->create();
     /** @var Fixture $fixture */
     $fixture = factory(Fixture::class)->create(['home_team_id' => $team->id]);
     $this->seeInDatabase('teams', ['id' => $team->id, 'club_id' => $team->club_id, 'team' => $team->team])->makeRequest('DELETE', route(self::BASE_ROUTE . '.destroy', [$team->id]))->seePageIs(route(self::BASE_ROUTE . '.index'))->seeInElement('#flash-notification .alert.alert-danger', 'Cannot delete because they are existing fixtures for this team.')->seeInDatabase('teams', ['id' => $team->id, 'club_id' => $team->club_id, 'team' => $team->team]);
     Fixture::destroy($fixture->id);
     /** @var Fixture $fixture */
     $fixture = factory(Fixture::class)->create(['away_team_id' => $team->id]);
     $this->seeInDatabase('teams', ['id' => $team->id, 'club_id' => $team->club_id, 'team' => $team->team])->makeRequest('DELETE', route(self::BASE_ROUTE . '.destroy', [$team->id]))->seePageIs(route(self::BASE_ROUTE . '.index'))->seeInElement('#flash-notification .alert.alert-danger', 'Cannot delete because they are existing fixtures for this team.')->seeInDatabase('teams', ['id' => $team->id, 'club_id' => $team->club_id, 'team' => $team->team]);
 }
コード例 #3
0
ファイル: FixturesController.php プロジェクト: troccoli/lva
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return mixed
  */
 public function destroy($id)
 {
     $canBeDeleted = empty(Fixture::find($id)->available_appointments->toArray());
     if ($canBeDeleted) {
         Fixture::destroy($id);
         \Flash::success('Fixture deleted!');
     } else {
         \Flash::error('Cannot delete because they are existing appointments for this fixture.');
     }
     return redirect('admin/data-management/fixtures');
 }
コード例 #4
0
ファイル: SeasonController.php プロジェクト: GlamCat/fifa
 /**
  * Remove season.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($season_id)
 {
     Season::destroy($season_id);
     Team::where('season_id', $season_id)->delete();
     Fixture::where('season_id', $season_id)->delete();
     LeagueTable::where('season_id', $season_id)->delete();
     return response()->json(['success' => true]);
 }
コード例 #5
0
ファイル: FixtureController.php プロジェクト: GlamCat/fifa
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $fixture_id
  * @return Response
  */
 public function update(Request $request, $fixture_id)
 {
     $fixture = Fixture::find($fixture_id);
     // Goals fields are empty
     //if($request->has(['home_team_id', 'away_team_id'])) {
     //        if(empty($request->home_team_goals) && empty($request->away_team_goals)) {
     //            $fixture->home_team_id = $request->home_team_id;
     //            $fixture->away_team_id = $request->away_team_id;
     //        }
     // Goals are isset
     if ($request->has(['home_team_goals', 'away_team_goals'])) {
         $fixture->home_team_goals = $request->home_team_goals;
         $fixture->away_team_goals = $request->away_team_goals;
         $home_previous = LeagueTable::where('team_id', $fixture->home_team_id)->orderBy('matchday', 'desc')->first();
         $away_previous = LeagueTable::where('team_id', $fixture->away_team_id)->orderBy('matchday', 'desc')->first();
         $home_current = $home_previous->replicate();
         $away_current = $away_previous->replicate();
         ++$home_current->matchday;
         ++$away_current->matchday;
         // Matches and points
         switch (true) {
             // Home team wins
             case $fixture->home_team_goals > $fixture->away_team_goals:
                 ++$home_current->matches_home_won;
                 ++$home_current->matches_won;
                 $home_current->points += 3;
                 ++$away_current->matches_away_lost;
                 ++$away_current->matches_lost;
                 break;
                 // Draw
             // Draw
             case $fixture->home_team_goals == $fixture->away_team_goals:
                 ++$home_current->matches_home_drawn;
                 ++$home_current->matches_drawn;
                 ++$home_current->points;
                 ++$away_current->matches_away_drawn;
                 ++$away_current->matches_drawn;
                 ++$away_current->points;
                 break;
                 // Away team wins
             // Away team wins
             case $fixture->home_team_goals < $fixture->away_team_goals:
                 ++$home_current->matches_home_lost;
                 ++$home_current->matches_lost;
                 ++$away_current->matches_away_won;
                 ++$away_current->matches_won;
                 $away_current->points += 3;
                 break;
         }
         // Goals
         switch (true) {
             // Home team doesn't score
             case $fixture->home_team_goals == 0:
                 ++$home_current->zero_for_home;
                 ++$home_current->zero_for;
                 ++$away_current->zero_against_away;
                 ++$away_current->zero_against;
                 break;
                 // Away team doesn't score
             // Away team doesn't score
             case $fixture->away_team_goals == 0:
                 ++$home_current->zero_against_home;
                 ++$home_current->zero_against;
                 ++$away_current->zero_for_away;
                 ++$away_current->zero_for;
                 break;
         }
         $home_current->goals_home_for += $fixture->home_team_goals;
         $home_current->goals_home_against += $fixture->away_team_goals;
         $home_current->goals_home_diff = $home_current->goals_home_for - $home_current->goals_home_against;
         $home_current->goals_for += $fixture->home_team_goals;
         $home_current->goals_against += $fixture->away_team_goals;
         $home_current->goals_diff = $home_current->goals_for - $home_current->goals_against;
         $away_current->goals_away_for += $fixture->away_team_goals;
         $away_current->goals_away_against += $fixture->home_team_goals;
         $away_current->goals_away_diff = $away_current->goals_away_for - $away_current->goals_away_against;
         $away_current->goals_for += $fixture->away_team_goals;
         $away_current->goals_against += $fixture->home_team_goals;
         $away_current->goals_diff = $away_current->goals_for - $away_current->goals_against;
         $home_current->save();
         $away_current->save();
     }
     $fixture->save();
     return response()->json(['success' => true]);
 }