Exemple #1
0
 public function getApplication()
 {
     $application = Application::with('school', 'team', 'ratings', 'notes')->firstOrCreate(['user_id' => $this->id]);
     if (!$application->team_id) {
         //assign them to a team of 1 in lieu of no team
         $team = new Team();
         $team->code = md5(Carbon::now() . getenv("APP_KEY"));
         $team->save();
         $application->team_id = $team->id;
     }
     $application->save();
     $application->teaminfo = $application->team;
     $application->schoolinfo = $application->school;
     return $application;
 }
 public function edit(Training $training)
 {
     $dayList = Training::getDayOfWeekList();
     $statusList = Training::getStatusList();
     $teamList = Team::lists('name', 'id');
     return view('backend.trainings.edit')->with('training', $training)->with('dayList', $dayList)->with('statusList', $statusList)->with('teamList', $teamList);
 }
Exemple #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $league = \App\Models\League::where(['name' => 'Bundesliga'])->first();
     if ($league) {
         if (\App\Models\Team::where(['leagueId' => $league->id])->count() > 2) {
             return false;
         }
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Schalke 04', 'logoPath' => 'teams-logo/schalke04.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Hertha BSC', 'logoPath' => 'teams-logo/hertha.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => '1. FC Köln', 'logoPath' => 'teams-logo/koln.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'FC Ingolstadt 04', 'logoPath' => 'teams-logo/ingolstadt.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Bayer Leverkusen', 'logoPath' => 'teams-logo/leverkusen.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => '1. FSV Mainz 05', 'logoPath' => 'teams-logo/mainz.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'VfL Wolfsburg', 'logoPath' => 'teams-logo/wolfsburg.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'SV Darmstadt 98', 'logoPath' => 'teams-logo/darmstadt.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Hamburger SV', 'logoPath' => 'teams-logo/hamburger.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Eintracht Frankfurt', 'logoPath' => 'teams-logo/eintracht.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Borussia Mönchengladbach', 'logoPath' => 'teams-logo/munchengladbach.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Werder Bremen', 'logoPath' => 'teams-logo/werder.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Hoffenheim', 'logoPath' => 'teams-logo/hoffenheim.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'FC Augsburg', 'logoPath' => 'teams-logo/augsburg.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Hannover 96', 'logoPath' => 'teams-logo/hannover.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'VfB Stuttgart', 'logoPath' => 'teams-logo/stuttgart.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     } else {
         $league = \App\Models\League::firstOrNew(['name' => 'Bundesliga', 'logoPath' => 'leagues-logo/bundesliga.png']);
         $league->save();
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'FC Bayern Munich', 'logoPath' => 'teams-logo/bayern.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
         DB::table('teams')->insert(['leagueId' => $league->id, 'name' => 'Borussia Dortmund', 'logoPath' => 'teams-logo/dortmund.png', 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]);
     }
 }
 public function actionIndex()
 {
     //没登录就回到主页
     if (Yii::$app->user->isGuest) {
         return $this->render('/site/index');
     }
     //没加入队伍就到/team/error页面
     if (User::findByUsername(Yii::$app->user->identity->username)->teamname == "") {
         return $this->render('/team/error', ['message' => '<h2>你还没有加入任何一个战队呢!</h2>']);
     }
     $myteamname = User::findByUsername(Yii::$app->user->identity->username)->teamname;
     $myteam = Team::findOne(['teamname' => $myteamname]);
     //上传文件
     $model = new UploadForm();
     if (Yii::$app->request->isPost) {
         if ($myteam->uploaded_time < 50) {
             $model->sourcecode = UploadedFile::getInstance($model, 'sourcecode');
             if ($id = $model->upload()) {
                 $myteam->uploaded_time++;
                 $myteam->save(false);
                 //上传成功就render到uploadsuccess页面
                 return $this->render('uploadsuccess', ['id' => $id]);
             }
         }
     }
     //上传文件$model,
     return $this->render('index', ['model' => $model, 'myteam' => $myteam]);
     //,'indexs'=>$indexs]);
 }
 public function edit(Player $player)
 {
     $users = ['' => ''] + User::lists('name', 'id')->all();
     $teams = Team::lists('name', 'id');
     $statuses = Player::$statuses;
     return view('backend.players.edit')->with('player', $player)->with('users', $users)->with('teams', $teams)->with('statuses', $statuses);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('frontend.main', function ($view) {
         $view->with('teamData', Team::find(config('mls.team_id')));
         $view->with('trainingData', TrainingRepository::getActiveList(config('mls.team_id')));
     });
 }
 /**
  * Match all newcomer without a team to a team
  *
  * Current algorithme put user of a branch inside one of the team
  * with the same branch (because we want to have PMOM with PMOM),
  * or if there is no team with the same branch, we put them in team
  * with null as a branch.
  */
 public static function matchTeams()
 {
     $newcomers = Newcomer::whereNull('team_id')->get();
     // Create an array to branch_id with number of newcomers in the team
     $countPerTeam = [];
     $teams = Team::all();
     foreach ($teams as $team) {
         if (!isset($countPerTeam[$team->branch])) {
             $countPerTeam[$team->branch] = [];
         }
         $countPerTeam[$team->branch][$team->id] = $team->newcomers->count();
     }
     foreach ($newcomers as $newcomer) {
         // Select teams associated with newcomer's branch if exist
         $branch = null;
         if (isset($countPerTeam[$newcomer->branch])) {
             $branch = $newcomer->branch;
         }
         // find teams with less newcomers and take it randomly
         $min = min($countPerTeam[$branch]);
         $keys = array_keys($countPerTeam[$branch], $min);
         $key = array_rand($keys);
         // set the new team and tell there is another number
         $newcomer->team_id = $keys[$key];
         $countPerTeam[$branch][$keys[$key]]++;
     }
     // Save it to DB
     foreach ($newcomers as $newcomer) {
         $newcomer->save();
     }
 }
Exemple #8
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]);
 }
Exemple #9
0
 private function performNameSearch($team_name)
 {
     if (empty($team_name)) {
         return array();
     }
     return \app\models\Team::find()->where(['like', 'name', $team_name])->all();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->startLog();
     $team = Team::find(self::TEAM_ID);
     if ($team == null) {
         $this->error('Team with id: ' . self::TEAM_ID . ' not found');
         exit;
     }
     $tournamentList = $this->tournament->getActiveScheduled();
     if ($tournamentList->count() < 1) {
         $this->error('No tournaments');
         exit;
     }
     $this->info('Tournaments count: ' . $tournamentList->count());
     foreach ($tournamentList as $key => $tournament) {
         $this->info('Tournament ' . ++$key . ': ' . $tournament->name);
         $html = new Htmldom($tournament->link);
         $table = $html->find('table.match-day', 0);
         if ($table == null) {
             $this->error('No matchday info');
             continue;
         }
         $gameList = $this->parseGameLinks($table, $team);
         $gameList = collect($gameList);
         $this->info('Games found: ' . $gameList->count());
         foreach ($gameList->reverse() as $game) {
             $game->setTournamentId($tournament->id);
             $game->setTeamId($team->id);
             $game->setSearchTeamName($team->name);
             (new GameRepository())->addParsedGame($game);
         }
     }
     $this->endLog();
 }
 public function actionIndex()
 {
     //没登录就回到主页
     if (Yii::$app->user->isGuest) {
         return $this->render('/site/index');
     }
     //没加入队伍就到/team/error页面
     if (User::findByUsername(Yii::$app->user->identity->username)->teamname == "") {
         return $this->render('/team/error', ['message' => '<h2>你还没有加入任何一个战队呢!</h2>']);
     }
     $myteamname = User::findByUsername(Yii::$app->user->identity->username)->teamname;
     $myteam = Team::findOne(['teamname' => $myteamname]);
     //上传文件
     $model = new UploadForm();
     if (Yii::$app->request->isPost) {
         if ($myteam->uploaded_time < 50) {
             $model->sourcecode = UploadedFile::getInstance($model, 'sourcecode');
             if ($id = $model->upload_first_round()) {
                 return $this->render('uploadsuccess');
             }
         }
     }
     $alreadysubmit = Firstroundcodes::find()->where(array('teamid' => $myteam->id))->exists();
     //上传文件$model,
     return $this->render('index', ['model' => $model, 'alreadysubmit' => $alreadysubmit, 'myteam' => $myteam]);
     //,'indexs'=>$indexs]);
 }
 public function invite(Request $request)
 {
     $limits = array(0, 2, 3, 99999999999, 0);
     $user = $request->user();
     $userId = $user->id;
     $userRole = $user->type;
     /**
      * Check if user has right to invite.
      * User has right if has no parent_user, has available limit and inviting email not registered
      */
     if ($user->parent_user) {
         $request->session()->flash('error', "Sorry you have no right to create team.");
         return redirect('team');
     }
     $email = $request->get('email');
     $member = User::where('email', '=', $email)->first();
     if ($member) {
         if (!$member->activation) {
             $request->session()->flash('error', "The invitation is already sent");
             return redirect('team');
         }
         $request->session()->flash('error', "Sorry, you can't send request to registered users.");
         return redirect('team');
     } else {
         $member = TeamInvitation::where('accept_email', '=', $request->get('email'))->first();
         if ($member) {
             $request->session()->flash('error', "Sorry, you can't send request to invited user.");
             return redirect('team');
         }
     }
     $existingMembers = Team::where('member_id', '=', $userId)->get();
     $expiredLimit = count($existingMembers) - 1;
     $invitedMembers = TeamInvitation::where('request_id', '=', $userId)->get();
     $expiredLimit += count($invitedMembers);
     if ($limits[$userRole] <= $expiredLimit) {
         $request->session()->flash('error', "Sorry, your limit is expired.");
         return redirect('team');
     } elseif ($request->user()->type == 4 || $request->user()->parent_user) {
         $request->session()->flash('error', "you can't invite team members");
         return redirect('team');
     }
     /**
      * Need create record in team_invitation
      */
     $teamInvitation = new TeamInvitation();
     $teamInvitation->request_id = $userId;
     $teamInvitation->request_user_email = $user->email;
     $activationCode = str_random(80);
     $teamInvitation->accept_id = $activationCode;
     $teamInvitation->accept_email = $email;
     $teamInvitation->status = 0;
     $teamInvitation->save();
     /**
      * Sending invitation email
      */
     //        $this->sendEmail($user->name, $user->email, $activationCode);
     $request->session()->flash('message', "Invitation successfully sent.");
     return redirect('team');
 }
Exemple #13
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return mixed
  */
 public function edit($id)
 {
     $fixture = Fixture::findOrFail($id);
     $divisions = Division::all();
     $teams = Team::all();
     $venues = Venue::all();
     return view('admin.data-management.fixtures.edit', compact('fixture', 'divisions', 'teams', 'venues'));
 }
Exemple #14
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);
     }
 }
Exemple #15
0
 public static function findByTeamname($teamname)
 {
     $team = Team::find()->where(array('teamname' => $teamname))->asArray()->one();
     if ($team) {
         return new static($team);
     }
     return null;
 }
 public function edit(Training $training)
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = Player::where('team_id', $team->id)->get();
     $visitMap = ['' => ''] + Stat::$visitList;
     $visitList = TrainingVisitRepository::getActiveTrainingVisits($training->id);
     $visitList = $visitList->lists('visit', 'player_id');
     return view('backend.training_visits.edit')->with('playerList', $playerList)->with('visitList', $visitList)->with('training', $training)->with('visitMap', $visitMap);
 }
 public function index()
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = PlayerRepository::getActiveListByTeamId($team->id);
     $gameList = GameRepository::getListByTeamId($team->id);
     $trainingList = TrainingRepository::getActiveList($team->id);
     $statList = StatRepository::getPlayersStatistics($playerList);
     return view('frontend.teams.view')->with('team', $team)->with('playerList', $playerList)->with('gameList', $gameList)->with('trainingList', $trainingList)->with('statList', $statList);
 }
 public function edit(Training $training)
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = PlayerRepository::getListByTeamId($team->id);
     $dayList = Training::getDayOfWeekList();
     $visitList = TrainingVisitRepository::getTrainingVisits($training->id);
     $visitList = $visitList->lists('visit', 'player_id');
     return view('frontend.trainings.edit')->with('training', $training)->with('team', $team)->with('playerList', $playerList)->with('dayList', $dayList)->with('visitList', $visitList)->with('statusVisited', Stat::GAME_VISITED)->with('statusNotVisited', Stat::GAME_NOT_VISITED);
 }
 public function edit(Game $game)
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = Player::where('team_id', $team->id)->get();
     $visitMap = ['' => ''] + Stat::$visitList;
     $visitList = StatRepository::getActiveVisitsForGame($game->id);
     $visitList = $visitList->lists(Stat::VISIT, 'player_id');
     return view('backend.visits.edit')->with('playerList', $playerList)->with('visitList', $visitList)->with('visitMap', $visitMap)->with('game', $game);
 }
 public function getReset()
 {
     $teams = Team::all();
     foreach ($teams as $team) {
         $team->games = 0;
         $team->wins = 0;
         $team->save();
     }
     return "Ok";
 }
Exemple #21
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);
 }
 public function index(Request $request)
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = PlayerRepository::getListByTeamId($team->id);
     $tournamentList = TournamentRepository::getListByTeamId($team->id);
     $selectedPlayerList = $request->get('playerList');
     $selectedTournamentList = $request->get('tournamentList');
     $filterPlayerList = $selectedPlayerList ? $selectedPlayerList : $playerList->lists('id')->all();
     $statList = StatRepository::getFilteredPlayersStatistics($filterPlayerList, $selectedTournamentList);
     return view('frontend.stats.view')->with('team', $team)->with('playerList', $playerList)->with('statList', $statList)->with('tournamentList', $tournamentList->lists('name', 'id'))->with('selectedPlayerList', $selectedPlayerList)->with('selectedTournamentList', $selectedTournamentList);
 }
Exemple #23
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;');
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Team::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'members', $this->members])->andFilterWhere(['like', 'program_id', $this->program_id]);
     return $dataProvider;
 }
Exemple #25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Team::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'teamname', $this->teamname])->andFilterWhere(['like', 'leadername', $this->leadername])->andFilterWhere(['like', 'member1name', $this->member1name])->andFilterWhere(['like', 'member2name', $this->member2name])->andFilterWhere(['like', 'member3name', $this->member3name])->andFilterWhere(['like', 'slogan', $this->slogan])->andFilterWhere(['like', 'key', $this->key]);
     return $dataProvider;
 }
 public function showVisit(Game $game)
 {
     $team = Team::find(config('mls.team_id'));
     $playerList = PlayerRepository::getActiveListByTeamId($team->id);
     if (!isset($game->id)) {
         $game = GameRepository::getNextGameByTeamId($team->id);
     }
     if (!$game) {
         return view('frontend.game.no_game');
     }
     $gameSiblings = GameRepository::getSiblings($game);
     $visitList = StatRepository::getVisitsForGame($game->id);
     $visitList = $visitList->lists(Stat::VISIT, 'player_id');
     return view('frontend.game.index')->with('team', $team)->with('playerList', $playerList)->with('game', $game)->with('visitList', $visitList)->with('gameSiblings', $gameSiblings)->with('statusVisited', Stat::GAME_VISITED)->with('statusNotVisited', Stat::GAME_NOT_VISITED);
 }
Exemple #27
0
 /**
  * Обновляет список команд пользователя
  */
 public function updateTeams()
 {
     if (!empty($this->profile_url)) {
         // Запоминаем старые команды
         $oldTeams = [];
         foreach ($this->teams as $team) {
             $oldTeams[] = $team->url;
         }
         // Получаем список новых команд
         $dom = Html::load($this->profile_url . 'fantasy/');
         $divs = $dom->getElementsByTagName('div');
         $host = 'https://www.sports.ru';
         foreach ($divs as $div) {
             if ($div->getAttribute('class') == 'item user-league') {
                 $links = $div->getElementsByTagName('a');
                 $tournamentUrl = $host . $links->item(1)->getAttribute('href');
                 if (preg_match('/.*\\/fantasy\\/football\\/.*/', $tournamentUrl)) {
                     // Проверяем турнир к которому относится команда
                     $tournament = Tournament::findOne(['url' => $tournamentUrl]);
                     if ($tournament === null) {
                         $tournament = new Tournament(['url' => $tournamentUrl, 'name' => $links->item(1)->nodeValue]);
                         $tournament->save();
                     }
                     // Добавляем команду
                     $teamUrl = $host . $links->item(0)->getAttribute('href');
                     $teamUrl = str_replace('/football/team/', '/football/team/points/', $teamUrl);
                     $team = Team::findOne(['url' => $teamUrl]);
                     if ($team === null) {
                         $team = new Team(['user_id' => $this->id, 'url' => $teamUrl, 'name' => $links->item(0)->nodeValue, 'tournament_id' => $tournament->id]);
                         $team->save();
                     } else {
                         $index = array_search($teamUrl, $oldTeams);
                         array_splice($oldTeams, $index, 1);
                     }
                 }
             }
         }
         // Удаляем старые команды
         foreach ($oldTeams as $url) {
             $team = Team::findOne(['url' => $url]);
             if ($team !== null) {
                 $team->delete();
             }
         }
     }
 }
 /**
  * Обновление дедлайнов турнира
  */
 public function actionDeadlines()
 {
     $tournaments = Tournament::find()->all();
     $month = ['января' => 1, 'февраля' => 2, 'марта' => 3, 'апреля' => 4, 'мая' => 5, 'июня' => 6, 'июля' => 7, 'августа' => 8, 'сентября' => 9, 'октября' => 10, 'ноября' => 11, 'декабря' => 12];
     foreach ($tournaments as $tournament) {
         $team = Team::findOne(['tournament_id' => $tournament->id]);
         if ($team !== null) {
             $dom = Html::load($team->url);
             $tables = $dom->getElementsByTagName('table');
             foreach ($tables as $table) {
                 if ($table->getAttribute('class') == 'profile-table') {
                     $trs = $table->getElementsByTagName('tr');
                     foreach ($trs as $tr) {
                         if ($tr->getElementsByTagName('th')->item(0)->nodeValue == 'Дедлайн') {
                             $deadline = $tr->getElementsByTagName('td')->item(0)->nodeValue;
                             $deadline = str_replace(['|', ':'], ' ', $deadline);
                             $deadline = explode(' ', $deadline);
                             if (count($deadline) == 4) {
                                 $year = date('Y');
                                 $time = mktime($deadline[2], $deadline[3], 0, $month[$deadline[1]], $deadline[0], $year);
                                 $now = time();
                                 if ($time < $now) {
                                     $year++;
                                     $time = mktime($deadline[2], $deadline[3], 0, $month[$deadline[1]], $deadline[0], $year);
                                 }
                                 $deadline = date('Y-m-d H:i:s', $time);
                             }
                         } elseif ($tr->getElementsByTagName('th')->item(0)->nodeValue == 'Трансферы в туре') {
                             $transfers = $tr->getElementsByTagName('td')->item(0)->nodeValue;
                         }
                     }
                 }
             }
             if ($tournament->deadline != $deadline) {
                 $tournament->deadline = $deadline;
                 if (isset($transfers)) {
                     $tournament->checked = false;
                     $tournament->transfers = $transfers;
                 } else {
                     $tournament->checked = true;
                 }
                 $tournament->save();
             }
         }
     }
 }
 /**
  * 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 !');
 }
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $branchs = Branch::all(['id', 'name']);
     $branchselectlist = array();
     array_push($branchselectlist, ':เลือกสาขา');
     foreach ($branchs as $item) {
         array_push($branchselectlist, $item->id . ':' . $item->name);
     }
     $departments = Department::all(['id', 'nameth', 'nameen']);
     $departmentselectlist = array();
     array_push($departmentselectlist, ':เลือกแผนก');
     foreach ($departments as $item) {
         array_push($departmentselectlist, $item->id . ':' . str_replace('&', '\\u0026', $item->nameth) . ' - ' . str_replace('&', '\\u0026', $item->nameen));
     }
     $teams = Team::all(['id', 'name']);
     $teamselectlist = array();
     array_push($teamselectlist, ':เลือกทีม');
     foreach ($teams as $item) {
         array_push($teamselectlist, $item->id . ':' . $item->name);
     }
     return view('employee', ['branchselectlist' => implode(";", $branchselectlist), 'departmentselectlist' => implode(";", $departmentselectlist), 'teamselectlist' => implode(";", $teamselectlist)]);
 }