public function checkChatWithInnovator($id) { if (Progress::where('investor_id', '=', \Auth::user()->id)->where('innovation_id', '=', $id)->exists()) { return true; } else { return false; } }
/** * Gets all innovations that are on progress * @return mixed */ public function getOnProgress() { return Progress::where('investor_id', '=', \Auth::user()->id)->where('progress_status', '=', 1)->with('innovation.category', 'innovation.user')->latest()->paginate(9); }
/** * Persists a message to the database * @param MessagesCreateRequest $request * @return \Illuminate\Http\RedirectResponse */ public function store(MessagesCreateRequest $request) { $input = $request; $innovation = Innovation::findOrFail($input['innovation_id']); $thread = Thread::create(['subject' => $input['subject'], 'innovation_id' => $input['innovation_id'], 'user_id' => \Auth::user()->id, 'receiver_id' => $innovation->user_id, 'unique_id' => str_random(30)]); $this->addReceiver($thread, $input['recipients']); // Message $message = Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => $input['message'], 'starter_id' => \Auth::user()->id, 'innovation_id' => $input['innovation_id']]); if (Input::has('progress')) { Progress::create(['innovation_id' => $input['innovation_id'], 'investor_id' => Auth::user()->id, 'progress_status' => 1]); } // Sender Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]); // Recipients if (Input::has('recipients')) { $thread->addParticipants($input['recipients']); } $this->oooPushIt($message); return redirect('innovation/' . $innovation->id . '#messages'); }