Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return mixed
  */
 public function store(Request $request)
 {
     $this->validate($request, ['club_id' => 'required|exists:clubs,id', 'team' => 'required|unique:teams,team,NULL,id,club_id,' . $request->get('club_id')]);
     Team::create($request->all());
     \Flash::success('Team added!');
     return redirect('admin/data-management/teams');
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('teams')->delete();
     Team::create(['name' => 'Manchester United', 'short_name' => 'Man Utd', 'season_id' => 1]);
     Team::create(['name' => 'Arsenal', 'short_name' => 'Arsenal', 'season_id' => 1]);
     Team::create(['name' => 'Queens Park Rangers', 'short_name' => 'QPR', 'season_id' => 1]);
 }
Exemplo n.º 3
0
 public function run()
 {
     DB::table('teams')->delete();
     $collection = [['teamleader_id' => 0, 'team_name' => 'Unassigned'], ['teamleader_id' => 25, 'team_name' => 'Gotham City'], ['teamleader_id' => 26, 'team_name' => 'Smallville'], ['teamleader_id' => 27, 'team_name' => 'Hells Kitchen']];
     foreach ($collection as $record) {
         Team::create($record);
     }
 }
Exemplo n.º 4
0
 /**
  * Create a new team.
  *
  * @return RedirectResponse|array
  */
 protected function create()
 {
     $data = Request::only(['name', 'description', 'img_url']);
     $team = Team::create($data);
     if ($team->save()) {
         return $this->success('Équipe ajoutée !');
     }
     return $this->error('Impossible d\'ajouter l\'équipe !');
 }
Exemplo n.º 5
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Team::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
Exemplo n.º 6
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('team_user')->truncate();
     DB::table('teams')->truncate();
     $faker = Faker::create();
     $users = Db::table('users')->lists('id');
     foreach (range(1, 30) as $key => $value) {
         $team = Team::create(['name' => $faker->name(), 'country' => $faker->country, 'city' => $faker->city]);
         $team->users()->sync([$faker->randomElement($users)]);
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Exemplo n.º 7
0
 /**
  * Store a newly created season.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $season = Season::create(['country' => $request->input('country'), 'league' => $request->input('league'), 'year' => $request->input('year'), 'number_of_teams' => $request->input('number_of_teams'), 'number_of_teams_to_cl' => $request->input('number_of_teams_to_cl'), 'number_of_teams_to_el' => $request->input('number_of_teams_to_el'), 'number_of_teams_to_ld' => $request->input('number_of_teams_to_ld')]);
     if ($request->has('link')) {
         // Example from football-data.org
         // England - Barclays Premier League - 2015
         // http://api.football-data.org/alpha/soccerseasons/398
         $link = $request->input('link');
         // Read data from link
         // $tmpTeamsFile = json_decode(file_get_contents($link."/teams"));
         // $tmpFixturesFile = json_decode(file_get_contents($link."/fixtures"));
         $base = base_path();
         $tmpTeamsFile = json_decode(file_get_contents($base . "/public/files/teams.json"));
         $tmpFixturesFile = json_decode(file_get_contents($base . "/public/files/fixtures.json"));
         $tmpTeams = $tmpTeamsFile->teams;
         $tmpFixtures = $tmpFixturesFile->fixtures;
         // Create teams
         foreach ($tmpTeams as $tmpTeam) {
             $team = Team::create(['name' => $tmpTeam->name, 'short_name' => $tmpTeam->code, 'season_id' => $season->id]);
             // Array of all teams from season
             $teams[] = $team;
         }
         // Create fixtures
         foreach ($tmpFixtures as $tmpFixture) {
             $home_team_name = $tmpFixture->homeTeamName;
             $away_team_name = $tmpFixture->awayTeamName;
             $home_team_index = $this->searchTeamIdByName($home_team_name, $teams);
             $away_team_index = $this->searchTeamIdByName($away_team_name, $teams);
             Fixture::create(['season_id' => $season->id, 'matchday' => $tmpFixture->matchday, 'home_team_id' => $teams[$home_team_index]->id, 'away_team_id' => $teams[$away_team_index]->id]);
         }
     } else {
         // Create teams
         for ($i = 1; $i <= $season->number_of_teams; $i++) {
             $team = Team::create(['name' => 'Team ' . sprintf("%02d", $i), 'short_name' => 'TN' . sprintf("%02d", $i), 'season_id' => $season->id]);
             $teams[] = $team;
         }
         // Create matchdays
         $tour = 1;
         $fixtures_in_tour = $season->number_of_teams / 2;
         for ($i = 1; $i <= $season->number_of_teams * ($season->number_of_teams - 1); $i++) {
             Fixture::create(['season_id' => $season->id, 'matchday' => $tour]);
             $tour = $i % $fixtures_in_tour == 0 ? ++$tour : $tour;
         }
     }
     // Create base league tables (tour #0)
     foreach ($teams as $team) {
         LeagueTable::create(['season_id' => $season->id, 'team_id' => $team->id]);
     }
     return response()->json(['success' => true]);
 }
Exemplo n.º 8
0
 /**
  * List all the teams and show a creation form.
  *
  * @return Response
  */
 public function teamCreate()
 {
     $this->validate(Request::instance(), ['name' => 'required|min:3|max:30|unique:teams'], ['name.unique' => 'Ce nom d\'équipe est déjà pris.']);
     // Create team
     $data = Request::only(['name']);
     $team = Team::create($data);
     $team->respo_id = EtuUTT::student()->student_id;
     if ($team->save()) {
         // Put user in the team
         $student = EtuUTT::student();
         $student->ce = true;
         $student->team_id = $team->id;
         $student->team_accepted = true;
         if ($student->save()) {
             return redirect(route('dashboard.ce.myteam'))->withSuccess('L\'équipe a été créé !');
         }
     }
     return $this->error('Impossible d\'ajouter l\'équipe !');
 }
Exemplo n.º 9
0
 public function run()
 {
     Team::create(['id' => 1, 'mls_id' => '182', 'name' => 'MightyDucks', 'link' => 'http://mls.od.ua/component/joomsport/team/70/182']);
 }
Exemplo n.º 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     Team::create(Request::all());
     return redirect('team');
 }