예제 #1
0
 public function store($asset_id, $meter_id)
 {
     if ($this->meterReadingValidator->passes()) {
         $asset = $this->asset->find($asset_id);
         $meter = $this->meter->find($meter_id);
         $data = $this->inputAll();
         $data['meter_id'] = $meter->id;
         /*
          * Check if duplicate reading entries are enabled
          */
         if ($this->config->get('rules.meters.prevent_duplicate_entries')) {
             /*
              * If the last reading is the same as the reading being inputted
              */
             if ($this->input('reading') === $meter->last_reading) {
                 /*
                  * Return warning message
                  */
                 $this->message = 'Please enter a reading different from the last reading';
                 $this->messageType = 'warning';
                 $this->redirect = route('maintenance.assets.meters.show', [$asset->id, $meter->id]);
                 return $this->response();
             }
         }
         if ($this->meterReading->setInput($data)->create()) {
             $this->message = 'Successfully updated reading';
             $this->messageType = 'success';
             $this->redirect = route('maintenance.assets.show', [$asset->id]);
         } else {
             $this->message = 'There was an error trying to update this meter. Please try again';
             $this->messageType = 'danger';
             $this->redirect = route('maintenance.assets.show', [$asset->id]);
         }
     } else {
         $this->errors = $this->meterReadingValidator->getErrors();
     }
     return $this->response();
 }
예제 #2
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.priorities');
 }
예제 #3
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.statuses');
 }
예제 #4
0
 /**
  * Retrieves the seed data from the maintenance configuration.
  *
  * @return mixed
  */
 private function getSeedData()
 {
     return $this->config->get('seed.metrics');
 }