本文整理汇总了PHP中app\Team::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::select方法的具体用法?PHP Team::select怎么用?PHP Team::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Team
的用法示例。
在下文中一共展示了Team::select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeteamscores
public function storeteamscores(Request $request)
{
$teams = new Team();
$teamsInfo = $teams->join('fantasy_user_players', 'fantasy_teams.team_id', '=', 'fantasy_user_players.team_id')->join('fantasy_match_scores', 'fantasy_user_players.id', '=', 'fantasy_match_scores.contract_id')->select('fantasy_teams.team_id', 'fantasy_teams.team_name', 'fantasy_teams.team_points', 'fantasy_user_players.match_player', 'fantasy_user_players.id as contract_id', 'fantasy_match_scores.match_id', 'fantasy_match_scores.points')->get();
$teamPoints = [];
foreach ($teams->select('team_id', 'team_points as points')->get() as $team) {
//$teamPoints = array_add($teamPoints, $team->team_id, $team->points);
$teamPoints[] = ['team_id' => $team->team_id, 'points' => $team->points];
}
//team_id, match_id, contract_id, points
foreach ($teamsInfo as $teamPlayer) {
$fantasyScores = new FantasyScores();
if ($teamPlayer->match_player == 1 && !$fantasyScores->where('match_id', $teamPlayer->match_id)->where('contract_id', $teamPlayer->contract_id)->first()) {
$fantasyScores->team_id = $teamPlayer->team_id;
$fantasyScores->match_id = $teamPlayer->match_id;
$fantasyScores->contract_id = $teamPlayer->contract_id;
$fantasyScores->points = $teamPlayer->points;
$fantasyScores->save();
//$teamPoints[$teamPlayer->team_id] += $teamPlayer->points;
foreach ($teamPoints as $teamPoint => $value) {
if ($teamPoints[$teamPoint]['team_id'] == $teamPlayer->team_id) {
$teamPoints[$teamPoint]['points'] += $teamPlayer->points;
}
}
}
}
/*foreach ($teamPoints as $teamPoint => $value) {
$teamPoints[$teamPoint]['points'] = $teamPoint['points'] + 10;
}*/
foreach ($teamPoints as $key => $value) {
DB::table('fantasy_teams')->where('team_id', $teamPoints[$key]['team_id'])->update(['team_points' => $teamPoints[$key]['points']]);
}
//$teamPoints = $teams->where('team_id', $teamPoints[$teams->team_id])->get();
return view('back.scores.index')->with('error', '')->with('qq', $teamPoints);
}