/**
  * Compare two users.
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     $user1Id = $request->input('user');
     $user2Id = $request->input('to');
     // todo: make sure both valid users, and they are different
     $user1 = $this->user->getUser($user1Id);
     $user2 = $this->user->getUser($user2Id);
     $user1Stats = $this->user->getUserStats($user1Id);
     $user2Stats = $this->user->getUserStats($user2Id);
     $user1BestRounds = $this->round->getBestRoundsByUser($user1Id, 5);
     $user2BestRounds = $this->round->getBestRoundsByUser($user2Id, 5);
     $users = compact('user1', 'user2');
     $stats = ['user1' => $user1Stats, 'user2' => $user2Stats];
     $bestRounds = ['user1' => $user1BestRounds, 'user2' => $user2BestRounds];
     return view('compare.index', compact('stats', 'users', 'bestRounds'));
 }
Ejemplo n.º 2
0
 /**
  * Display the user.
  *
  * @param $userId
  * @return Response
  */
 public function show($userId)
 {
     $user = $this->user->getUser($userId);
     $stats = $this->user->getUserStats($userId);
     $parStats = [];
     $parStats['par3'] = $this->user->getUserStatsByPar($userId, 3);
     $parStats['par4'] = $this->user->getUserStatsByPar($userId, 4);
     $parStats['par5'] = $this->user->getUserStatsByPar($userId, 5);
     $chartData = [];
     foreach ($parStats as $key => $stat) {
         $chartData[$key][] = ['label' => 'Eagles', 'count' => $stat->total_eagles];
         $chartData[$key][] = ['label' => 'Birdies', 'count' => $stat->total_birdies];
         $chartData[$key][] = ['label' => 'Pars', 'count' => $stat->total_pars];
         $chartData[$key][] = ['label' => 'Bogies', 'count' => $stat->total_bogies];
         $chartData[$key][] = ['label' => 'Doubles', 'count' => $stat->total_double_bogies];
     }
     $latestRounds = $this->round->getLatestRoundsByUser($userId, 5);
     $bestRounds = $this->round->getBestRoundsByUser($userId, 5);
     return view('users.show', compact('user', 'latestRounds', 'bestRounds', 'stats', 'chartData'));
 }