/** * Retrieves a specific innovation with its related data * @param $id * @param ConversationRepository $conversationRepository * @return \Illuminate\View\View */ public function show($id, ConversationRepository $conversationRepository) { $innovation = $this->repo->retrieve($id); $check_chat = $conversationRepository->chatExists($id); $currentUserId = Auth::user()->id; $chatWithInnovator = $conversationRepository->checkChatWithInnovator($id); $mother = User::where('id', '=', $innovation->moderator_id)->first(); $users = User::where('userCategory', '=', 3)->get(); $investors = User::where('userCategory', '=', 2)->get(); // All threads that user is participating in $threads = Thread::forUser($currentUserId)->where('innovation_id', '=', $id)->get(); $threads_count = $threads->count(); if (\Auth::user()->isInvestor()) { if (Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->exists() == true) { $thread = Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first(); } } if (\Auth::user()->isMother()) { if (Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->exists() == true) { $thread_mother = Thread::where('innovation_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->first(); } else { $thread_mother = null; } } $funds = $this->repo->getPortfolio($id); $totalNeeded = $this->repo->getInnovationFund($id); return view('innovation.show', compact('totalNeeded', 'funds', 'thread_mother', 'thread', 'investors', 'mother', 'users', 'chatWithInnovator', 'innovation', 'id', 'check_chat', 'message', 'threads', 'threads_count', 'currentUserId')); }