/**
  * Move conversation
  *
  * @param int $conversation_id
  * @param string $label
  */
 public function moveToLabel($conversation_id, $label)
 {
     $users = new Users();
     $labels = new Labels();
     $available_labels = [Labels::TYPE_INBOX, Labels::TYPE_TRASH, Labels::TYPE_ARCHIVE];
     /**
      * Wrong label
      */
     if (in_array($label, $available_labels) === false) {
         return \Redirect::to('mail');
     }
     /**
      * Wrong conversation ID
      */
     if ($users->isUserInConversation(\Auth::user()->id, $conversation_id) === false) {
         return \Redirect::to('mail');
     }
     $label_id = $labels->getLabelByUserIdAndType(\Auth::user()->id, $label);
     if ($label_id === null) {
         $label_id = $labels->getUserInboxID(\Auth::user()->id);
     } else {
         $label_id = $label_id->label_id;
     }
     $users->updateLabelId($conversation_id, \Auth::user()->id, $label_id);
     return \Redirect::to('mail/l/' . $label);
 }
Exemplo n.º 2
0
 /**
  * Show messages from conversation
  *
  * @param int $conversation_id
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showConversation($conversation_id)
 {
     /**
      * Sprawdzanie, czy taka konwersacja istnieje i czy mam do niej dostęp
      */
     $conversations = new Conversations();
     $users = new Users();
     if ($users->isUserInConversation(\Auth::user()->id, $conversation_id) === false) {
         return \Redirect::to('mail');
     }
     /**
      * Mark as read
      */
     $users->markAsRead($conversation_id, \Auth::user()->id);
     return view('mail.messages.conversation', ['conversation' => $conversations->getById($conversation_id)]);
 }