Ejemplo n.º 1
0
 /**
  * @return \Illuminate\Support\Collection
  */
 public function unreadConversations()
 {
     $conversations = $this->conversationRepository->getUnreadForUser($this->wrappedObject);
     foreach ($conversations as $key => $conversation) {
         $conversations[$key] = app()->make('MyBB\\Core\\Presenters\\Conversation', [$conversation]);
     }
     return $conversations;
 }
Ejemplo n.º 2
0
 /**
  * @param int                $id
  * @param ParticipantRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postNewParticipant($id, ParticipantRequest $request)
 {
     /** @var Conversation $conversation */
     $conversation = $this->conversationRepository->find($id);
     if (!$conversation || !$conversation->participants->contains($this->guard->user())) {
         throw new ConversationNotFoundException();
     }
     try {
         $this->conversationRepository->addParticipants($conversation, $request->getUseridArray('participants'));
     } catch (ConversationCantSendToSelfException $exception) {
         return redirect()->route('conversations.newParticipant', ['id' => $conversation->id])->withInput()->withErrors(['participants' => $exception->getMessage()]);
     } catch (ConversationAlreadyParticipantException $exception) {
         return redirect()->route('conversations.newParticipant', ['id' => $conversation->id])->withInput()->withErrors(['participants' => $exception->getMessage()]);
     }
     return redirect()->route('conversations.read', ['id' => $conversation->id])->withSuccess('Added participants');
 }