Example #1
0
 /**
  * @return string
  */
 protected function getArticleAttribute()
 {
     $path = $this->path;
     $file = $this->file;
     try {
         return app('files')->get("{$path}/{$file}");
     } catch (\Exception $e) {
         \Log::error($e->getMessage());
     }
     return '';
 }
Example #2
0
 /**
  * Given the test category name we return the test category ID
  *
  * @param $testcategory - the name of the test category
  */
 public static function getTestCatIdByName($testCategory)
 {
     try {
         $testCatId = TestCategory::where('name', 'like', $testCategory)->firstOrFail();
         return $testCatId->id;
     } catch (ModelNotFoundException $e) {
         Log::error("The test category ` {$testCategory} ` does not exist:  " . $e->getMessage());
         //TODO: send email?
         return null;
     }
 }
Example #3
0
 /**
  * Return field ID given the name
  * @param $name the name of the field
  */
 public static function idByName($name = NULL)
 {
     if ($name) {
         try {
             $field = Field::where('field_name', $name)->orderBy('field_name', 'asc')->firstOrFail();
             return $field->id;
         } catch (ModelNotFoundException $e) {
             Log::error("The field ` {$name} ` does not exist:  " . $e->getMessage());
             //TODO: send email?
             return null;
         }
     } else {
         return null;
     }
 }
Example #4
0
 /**
  *	beforeSave.
  *
  *	Validates before saving.  Returns whether the Group can be saved.
  *
  *	@param array $options
  *
  *	@return bool
  */
 private function beforeSave(array $options = array())
 {
     if (!$this->validate()) {
         Log::error("Unable to validate group: ");
         Log::error($this->getErrors()->toArray());
         Log::error($this->attributes);
         return false;
     }
     return true;
 }
Example #5
0
 public function updateInventory($flightID, $flightWebsiteID, $event, $overReport = false)
 {
     $trackInventory = $overReport ? new TrackingOverInventory() : new TrackingInventory();
     try {
         $trackInventory->incTotalAdZoneInventory($flightID, $flightWebsiteID, $event);
         $trackInventory = $overReport ? new TrackingOverInventory() : new TrackingInventory();
         $trackInventory->incTotalInventory($flightID, $event);
         return true;
     } catch (Exception $exception) {
         Log::error($exception);
         throw $exception;
         return false;
     }
 }
Example #6
0
 /**
  * Save instrument
  *
  * @param String machineCode, String ip, optional String hostname
  * @return String success/failure message
  */
 public static function saveInstrument($code, $ip, $hostname = "")
 {
     $plugin = Instrument::getInstalledPlugins(true);
     $className = "";
     // Get the class name of the user selected plugin
     foreach ($plugin as $key => $plug) {
         // If the instrument_code matches that of the select box, WE HAVE A MATCH
         if ($key == $code) {
             $className = $plug['class'];
             break;
         }
     }
     if (class_exists($className)) {
         $instrument = new $className($ip);
         $deviceInfo = $instrument->getEquipmentInfo();
         $newInstrument = new Instrument();
         $newInstrument->name = $deviceInfo['name'];
         $newInstrument->description = $deviceInfo['description'];
         $newInstrument->driver_name = $className;
         $newInstrument->ip = $ip;
         $newInstrument->hostname = Input::get('hostname');
         try {
             $newInstrument->save();
             $newInstrument->setTestTypes($deviceInfo['testTypes']);
             return trans('messages.success-creating-instrument');
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
     return trans('messages.failure-creating-instrument');
 }
Example #7
0
 /**
  * Given the measure name we return the measure ID
  *
  * @param $measureName the name of the measure
  */
 public static function getMeasureIdByName($measureName)
 {
     try {
         $measure = Measure::where('name', 'like', $measureName)->firstOrFail();
         return $measure->id;
     } catch (ModelNotFoundException $e) {
         Log::error("The measure ` {$measureName} ` does not exist:  " . $e->getMessage());
         //TODO: send email?
         return null;
     }
 }
Example #8
0
 /**
  * Given the test name we return the test type ID
  *
  * @param $testname the name of the test
  */
 public static function getTestTypeIdByTestName($testName)
 {
     try {
         $testName = trim($testName);
         $testTypeId = TestType::where('name', 'like', $testName)->orderBy('name')->firstOrFail();
         return $testTypeId->id;
     } catch (ModelNotFoundException $e) {
         \Log::error("The test type ` {$testName} ` does not exist:  " . $e->getMessage());
         //TODO: send email?
         return null;
     }
 }