/** * 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(); }
private function performNameSearch($team_name) { if (empty($team_name)) { return array(); } return \app\models\Team::find()->where(['like', 'name', $team_name])->all(); }
/** * 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'))); }); }
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 = 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(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(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 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); }
/** * 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; }
/** * 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); }
/** * 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; } $html = new Htmldom($team->link); $team_table = $html->find('table.team-list', 0); if ($team_table == null) { $this->error('Team table not found on this page: ' . $team->link); exit; } $player_links = []; foreach ($team_table->find('p.player-name a') as $link) { if (isset($link->href)) { array_push($player_links, $link->href); } } if (count($player_links) < 1) { $this->error('No players found'); exit; } $this->comment('Found players: ' . count($player_links)); $bar = $this->output->createProgressBar(count($player_links)); foreach ($player_links as $link) { if (strpos($link, self::DOMAIN) === false) { $link = self::DOMAIN . $link; } $player = new Player(); $player->team_id = self::TEAM_ID; $player->mls_id = $this->parseIdFromUrl($link); $player_html = new Htmldom($link); if ($player_html == null) { continue; } $player_table = $player_html->find('table.adf-fields-table', 0); if ($player_table == null) { continue; } foreach ($player_table->find('tr') as $row) { $td1 = $row->find('td', 0); $td2 = $row->find('td', 1); if ($td1 != null && strpos($td1->innertext, 'Полное имя') !== false) { $player->name = $td2->plaintext; } if ($td1 != null && strpos($td1->innertext, 'Дата рождения') !== false) { $player->date_of_birth = Carbon::parse($td2->plaintext); } } $check_player = Player::where('mls_id', $player->mls_id)->where('name', $player->name)->where('team_id', $player->team_id)->where('date_of_birth', $player->date_of_birth)->first(); if ($check_player) { $player->id = $check_player->id; $player->update(); } else { $player->save(); } $img = $player_html->find('div#etab_player_div div.gray-box img', 0); if ($img != null && $img->src != null && strpos($img->src, self::DEFAULT_IMG) === false) { $src = $img->src; if (strpos($src, self::DOMAIN) === false) { $src = self::DOMAIN . $src; } copy($src, public_path() . '/img/avatars/players/' . $player->id . '.jpg'); } $bar->advance(); } $bar->finish(); $this->endLog(); }
/** * Remove the specified resource from storage. * * @param int $id * * @return mixed */ public function destroy($id) { $team = Team::find($id); $canBeDeleted = empty($team->homeFixtures->toArray()) && empty($team->awayFixtures->toArray()); if ($canBeDeleted) { Team::destroy($id); \Flash::success('Team deleted!'); } else { \Flash::error('Cannot delete because they are existing fixtures for this team.'); } return redirect('admin/data-management/teams'); }
public function actionIndex() { //没登录就回到主页 if (Yii::$app->user->isGuest) { return $this->render('/site/index'); } $myteamname = User::findByUsername(Yii::$app->user->identity->username)->teamname; //没加入队伍就到/team/error页面 if ($myteamname == "") { return $this->render('/team/error', ['message' => '<h2>你还没有加入任何一个战队呢!</h2>']); } //$myteam = Team::findByTeamname($myteamname); $myteam = Team::findOne(['teamname' => $myteamname]); //我已上传成功的代码 $mycodes = Sourcecodes::find()->where(['team' => $myteamname])->orderBy('uploaded_at DESC')->all(); $mycodes2 = $mycodes; foreach ($mycodes2 as $mycode) { $mycode->uploaded_at = $mycode->id . '号,上传于' . $mycode->uploaded_at; } //已上传代码的队伍,除掉自己所在的队伍 $teamnames = Sourcecodes::find()->select('team')->where("team<>'{$myteamname}'")->distinct()->orderBy('uploaded_at DESC'); $teams = Team::find()->where(['teamname' => $teamnames])->all(); //别的队伍的代码 $otherscodes = Sourcecodes::find()->where("team<>'{$myteamname}'")->select('uploaded_at')->orderBy('uploaded_at DESC')->column(); //对战结果 $results1 = Battleresult::find(); //对战结果分页器 $pagination = new Pagination(['defaultPageSize' => 20, 'totalCount' => $results1->count()]); $results = $results1->orderBy('battle_at DESC')->offset($pagination->offset)->limit($pagination->limit)->all(); //表单 $model = new BattleForm(); //上传文件$model, if ($model->load(Yii::$app->request->post())) { if ($myteam->battled_time < 200) { //如果对战次数还没到10次 $myteam->battled_time++; $myteam->save(false); $model->myteam = $myteam->id; //我方代码编号 $model->mycode = $_POST['BattleForm']['mycode']; //敌方队伍名称 $model->enemyteam = $_POST['BattleForm']['enemyteam']; //敌方代码编号 $model->enemycode = $_POST['BattleForm']['enemycode']; $result = new Battleresult(); $result->team1 = $myteamname; $result->ai1 = $model->mycode; $result->team2 = Team::findOne(['id' => $model->enemyteam])->teamname; $result->ai2 = $model->enemycode; date_default_timezone_set('PRC'); $result->battle_at = date("Y-m-d H:i:s"); $result->result = '对战中'; $result->save(); $model->id = $result->id; $re = $model->battle(); return $this->redirect(['index']); } else { print "哥们你对战太多次了<br>明天再来吧~"; } die; } return $this->render('index', ['model' => $model, 'myteam' => $myteam, 'mycodes' => $mycodes2, 'teams' => $teams, 'otherscodes' => $otherscodes, 'results' => $results, 'pagination' => $pagination]); }
public function leaveCurrentTeam() { $app = self::getApplication()['application']; $old_team_id = $app->team_id; $app->team_id = null; $app->save(); if (Application::where("team_id", $old_team_id)->get()->count() == 0) { //we don't want empty teams Team::find($old_team_id)->delete(); } return ['ok']; }
public function getEditTeam(LoggedInRequest $request, $id = 0) { if ($id == 0) { $teams = Team::all(); return view('pages.teams', compact('teams')); } $team = Team::find($id); return view('pages.team-detail', compact('team')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($plan_id, $id) { // check access rights if (!Auth::user()->ownsPlan($plan_id)) { return redirect('home')->with('error', 'You are unauthorized for this request.'); } // get the resource handle $team = Team::find($id); if ($team) { $team->delete(); $status = 'Team Member removed from this plan.'; return \Redirect::route('team.index', ['plan_id' => $plan_id])->with(['status' => $status]); } $error = 'Wrong team member id!'; return \Redirect::back()->with(['error' => $error]); }
public function actionTeams() { $res = []; /* $m = Matches::find() ->select(['host, COUNT(*) as cnt']) ->groupBy('host') ->all(); */ $m = Team::find()->all(); foreach ($m as $h) { //echo substr($h->host, 1); if ($h->adapt_name) { $res[] = $h->adapt_name; } else { $res[] = $h->name; } } return json_encode($res); }
public function adminUnvalidate($id) { $team = Team::find($id); if ($team) { $team->validated = false; $team->save(); return $this->success('L\'équipe a été désapprouvée !'); } return $this->error('L\'equipe n\'a pas été trouvé !'); }