/** * 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')); }