Inheritance: extends Illuminate\Database\Eloquent\Model
 /**
  * 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();
 }
 /**
  * Links case to user (person who replied)
  *
  * @param object $case
  *
  * @return void
  */
 private function linkCaseToUser($case)
 {
     $case = $this->case->find($case->id);
     if (!$case->users->contains(Auth::user()->id)) {
         $case->users()->attach(Auth::user()->id);
     }
 }
 /**
  * Update case with newest Facebook or Tweet id
  * @param  integer $caseId
  * @param  integer $messageId
  * @param  string $type
  * @return void
  */
 private function updateCase($caseId, $type, $messageId)
 {
     $case = $this->case->find($caseId);
     if ($type == 'twitter') {
         $case->latest_tweet_id = $messageId;
     } else {
         $case->latest_fb_id = $messageId;
     }
     $case->save();
 }
 /**
  * Gets average helpers per case
  *
  * @return integer
  */
 private function getAvgHelpers()
 {
     $cases = $this->case->ClosedCases();
     $counter = 0;
     foreach ($cases as $key => $case) {
         $counter += count($case->users);
     }
     if ($counter > 0) {
         return round($counter / count($cases), 1);
     }
     return 0;
 }
 /**
  * Inserts new case in DB
  * @param  string $type
  * @param  array $message
  * @param  object $contact
  * @return object
  */
 public function createCase($type, $message, $contact)
 {
     $case = new CaseOverview();
     $case->contact_id = $contact->id;
     if ($type == 'twitter_mention') {
         $case->origin = "Twitter mention";
     } else {
         if ($type == 'twitter_direct') {
             $case->origin = "Twitter direct";
         } else {
             if ($type == 'facebook_post') {
                 $case->origin = "Facebook post";
             } else {
                 if ($type == "facebook_private") {
                     $case->origin = 'Facebook private';
                 }
             }
         }
     }
     $case->status = 0;
     $case->save();
     return $case;
 }