openCase() public method

Changes status of case to "open"
public openCase ( object $case ) : void
$case object
return void
 /**
  * Add summary to case
  *
  * @param Request $request
  * @param integer  $caseId
  *
  * @return view
  */
 public function addSummary(Request $request, $caseId)
 {
     $summary = new Summary();
     $summary->case_id = $caseId;
     $summary->user_id = Auth::user()->id;
     $summary->summary = $request->input('summary');
     $summary->save();
     $case = $this->case->find($caseId);
     $this->case->openCase($case);
     Session::flash('flash_success', trans('crm-launcher::success.summary_added'));
     return back();
 }
Exemplo n.º 2
0
 /**
  * Gets all direct (private) messages on Twitter
  * @return void
  */
 public function collectDirectMessages()
 {
     $sinceId = latestDirect();
     $directs = $this->twitterContent->fetchDirectMessages($sinceId);
     foreach ($directs as $key => $direct) {
         $date = changeDateFormat($direct['created_at']);
         $message = new Message();
         if ($this->contact->where('twitter_id', $direct['sender']['id_str'])->exists()) {
             $contact = $this->contact->where('twitter_id', $direct['sender']['id_str'])->first();
             if (count($contact->cases)) {
                 $case = $contact->cases()->where('origin', 'Twitter direct')->orderBy('id', 'DESC')->first();
             } else {
                 $case = $this->case->createCase('twitter_direct', $direct, $contact);
             }
             $message->case_id = $case->id;
             $this->case->openCase($case);
         } else {
             $contact = $this->contact->createContact('twitter_direct', $direct);
             $case = $this->case->createCase('twitter_direct', $direct, $contact);
             $message->case_id = $case->id;
         }
         $message->contact_id = $contact->id;
         $message->direct_id = $direct['id_str'];
         $message->message = filterUrl($direct['text']);
         $message->post_date = $date;
         $message->save();
         $this->media->handleMedia($message->id, $direct, 'twitter');
         $this->updateCase($case->id, 'twitter', $direct['id_str']);
     }
 }
Exemplo n.º 3
0
 /**
  * Inserts answer to database
  *
  * @param  string $type
  * @param  Request $request
  * @param  object $case
  * @param  string $message
  * @param  string $reply
  * @param  string $handle
  *
  * @return void
  */
 private function insertAnswer($type, $request, $case, $message, $reply, $handle)
 {
     $answer = new Answer();
     $answer->case_id = $case->id;
     $answer->user_id = Auth::user()->id;
     $answer->answer = $request->input('answer');
     $answer->post_date = Carbon::now();
     if (is_a($message, "Rubenwouters\\CrmLauncher\\Models\\Answer")) {
         $answer->answer_id = $message->id;
     } else {
         $answer->message_id = $message->id;
     }
     if ($type == self::TYPE_TWEET) {
         $answer->tweet_id = $reply['id_str'];
         if ($case->origin == 'Twitter mention') {
             if ($reply['in_reply_to_status_id_str'] != null) {
                 $answer->tweet_reply_id = $reply['in_reply_to_status_id_str'];
             } else {
                 $answer->tweet_reply_id = 0;
             }
         }
     } else {
         if ($type == self::TYPE_FACEBOOK_POST) {
             $answer->fb_post_id = $reply->id;
             $answer->fb_reply_id = $message->fb_post_id;
         } else {
             if ($type == self::TYPE_FACEBOOK_PRIVATE) {
                 $answer->fb_private_id = $reply->id;
                 $answer->fb_reply_id = $message->fb_conversation_id;
             }
         }
     }
     $answer->save();
     $this->case->openCase($case);
     $this->linkCaseToUser($case);
 }