fork download
  1. public function getTournamentSeasonStatisticPlayerBombardiers($tournamentSeason)
  2. {
  3. return Player::whereHas('positionFirstMatchLogs', function ($query) use ($tournamentSeason) {
  4. $query->whereHas('match', function ($query) use ($tournamentSeason) {
  5. $query->ofTournamentSeason($tournamentSeason->id);
  6. })->goalAmount();
  7. })
  8. //->select('players.name','players.slug', 'players.big_image', 'players.small_image', 'players.position')
  9. ->with('currentTeam')
  10. // ->with([
  11. // 'playerTeams' => function ($query) use ($tournamentSeason) {
  12. // $query->with(array('team' => function ($team) {
  13. // $team->select('id', 'name', 'logotip', 'slug');
  14. // }))
  15. // ->season($tournamentSeason->start_date, $tournamentSeason->finish_date);
  16. // }
  17. // ])
  18. ->withCount([
  19. 'positionFirstMatchLogs as goals_count' => function ($query) use ($tournamentSeason) {
  20. $query->whereHas('match', function ($query) use ($tournamentSeason) {
  21. $query->ofTournamentSeason($tournamentSeason->id);
  22. })->goalAmount();
  23. },
  24. 'positionFirstMatchLogs as penalty_goals_count' => function ($query) use ($tournamentSeason) {
  25. $query->whereHas('match', function ($query) use ($tournamentSeason) {
  26. $query->ofTournamentSeason($tournamentSeason->id);
  27. })->penalty();
  28. },
  29. 'positionFirstMatchLogs as matches_count' => function ($query) use ($tournamentSeason) {
  30. $query->whereHas('match', function ($query) use ($tournamentSeason) {
  31. $query->ofTournamentSeason($tournamentSeason->id)->playedMatch();
  32. });
  33. },
  34. ])
  35. ->orderBy('goals_count', 'DESC')
  36. ->orderBy('matches_count', 'ASC')
  37. ->paginate(10);
  38. }
Success #stdin #stdout 0.02s 24180KB
stdin
Standard input is empty
stdout
public function getTournamentSeasonStatisticPlayerBombardiers($tournamentSeason)
    {
        return Player::whereHas('positionFirstMatchLogs', function ($query) use ($tournamentSeason) {
            $query->whereHas('match', function ($query) use ($tournamentSeason) {
                $query->ofTournamentSeason($tournamentSeason->id);
            })->goalAmount();
        })
            //->select('players.name','players.slug', 'players.big_image', 'players.small_image', 'players.position')
            ->with('currentTeam')
            // ->with([
            //     'playerTeams' => function ($query) use ($tournamentSeason) {
            //         $query->with(array('team' => function ($team) {
            //             $team->select('id', 'name', 'logotip', 'slug');
            //         }))
            //             ->season($tournamentSeason->start_date, $tournamentSeason->finish_date);
            //     }
            // ])
            ->withCount([
                'positionFirstMatchLogs as goals_count' => function ($query) use ($tournamentSeason) {
                    $query->whereHas('match', function ($query) use ($tournamentSeason) {
                        $query->ofTournamentSeason($tournamentSeason->id);
                    })->goalAmount();
                },
                'positionFirstMatchLogs as penalty_goals_count' => function ($query) use ($tournamentSeason) {
                    $query->whereHas('match', function ($query) use ($tournamentSeason) {
                        $query->ofTournamentSeason($tournamentSeason->id);
                    })->penalty();
                },
                'positionFirstMatchLogs as matches_count'  => function ($query) use ($tournamentSeason) {
                    $query->whereHas('match', function ($query) use ($tournamentSeason) {
                        $query->ofTournamentSeason($tournamentSeason->id)->playedMatch();
                    });
                },
            ])
            ->orderBy('goals_count', 'DESC')
            ->orderBy('matches_count', 'ASC')
            ->paginate(10);
    }