示例#1
0
 /**
  * Wrapper for save data.
  *
  * @return bool
  */
 public function save()
 {
     /*
      * save evidence into table
      **/
     $this->evidence->save();
     /*
      * call saver
      **/
     $saver = new IncidentsSave();
     $saverResult = $saver->save($this->incidents, $this->evidence->id);
     /*
      * We've hit a snag, so we are gracefully killing ourselves
      * after we contact the admin about it. IncidentsSave should never
      * end with problems unless the mysql died while doing transactions
      **/
     if ($saverResult['errorStatus'] === true) {
         Log::error(get_class($saver) . ': ' . 'Saver has ended with errors ! : ' . $saverResult['errorMessage']);
         return false;
     }
     $linkedEvents = Event::where('evidence_id', '=', $this->evidence->id);
     if ($linkedEvents->count() == 0) {
         Log::info(get_class($saver) . ': ' . 'The evidence submitted was never linked to any ticket, thus removing it from the DB again');
         $this->evidence->forceDelete();
     }
     Log::info(get_class($saver) . ': ' . 'Saver has ended without errors');
     return true;
 }