/** * Show the application dashboard to the user. * * @param Request $request * @return Response */ public function index(Request $request) { $user = $request->user(); $rounds = $this->round->getRoundsByUser($user->id); $latestRounds = $rounds->take(-5)->reverse(); $trends = $this->user->getUserTrends($rounds); $feed = $this->user->getUserLatestFeed($user->id, 5); $chartData = []; foreach ($rounds as $round) { $chartData[] = ['date' => $round->date->format('Y-m-d'), 'strokes' => $round->totalStrokes(), 'putts' => $round->totalPutts()]; } return view('home', ['rounds' => $rounds, 'latestRounds' => $latestRounds, 'chartData' => $chartData, 'trends' => $trends, 'user' => $user, 'feed' => $feed]); }
/** * 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')); }
/** * Display a feed of rounds played by users this user is following. * * @param $userId * @return \Illuminate\View\View */ public function feed($userId) { $user = $this->user->getUser($userId); $feed = $this->user->getUserPaginatedFeed($user->id, 10); return view('users.feed', compact('user', 'feed')); }