Ejemplo n.º 1
0
 public static function updateValues(array $attributes, array &$values = [], $type, $fields)
 {
     $object_id = $attributes[$fields[config("constants.keyField")]];
     $values = static::updateDependenceFields($object_id, $values);
     if (array_key_exists(config("constants.extraFields"), $fields)) {
         $occur_date = $attributes["OCCUR_DATE"];
         $extraFields = $fields[config("constants.extraFields")];
         $sourceFields = array_keys($extraFields);
         // 			\DB::enableQueryLog();
         $yesterdayRecord = static::where('OCCUR_DATE', '=', $occur_date->copy()->subDay())->where(static::$idField, '=', $object_id)->select($sourceFields)->first();
         // 			\Log::info(\DB::getQueryLog());
         if ($yesterdayRecord != null) {
             foreach ($extraFields as $sourceField => $targetField) {
                 if ($yesterdayRecord->{$sourceField} > 0 || $yesterdayRecord->{$sourceField} === 0) {
                     $values[$targetField] = $yesterdayRecord->{$sourceField};
                 }
             }
         }
     }
     if (array_key_exists(config("constants.mainFields"), $fields)) {
         $mainFields = $fields[config("constants.mainFields")];
         $mainFields[config("constants.keyField")] = $fields[config("constants.keyField")];
         parent::updateValues($attributes, $values, $type, $mainFields);
     }
 }
Ejemplo n.º 2
0
 public static function updateWithFormularedValues($values, $object_id, $occur_date, $flow_phase)
 {
     $newData = [static::$idField => $object_id, config("constants.euFlowPhase") => $flow_phase];
     $attributes = static::getKeyColumns($newData, $occur_date, null);
     $values = array_merge($values, $newData);
     return parent::updateOrCreate($attributes, $values);
 }
Ejemplo n.º 3
0
 public function delete()
 {
     // Delete all of the products that have the same ids...
     QltyDataDetail::where("QLTY_DATA_ID", $this->primaryKey)->delete();
     // Finally, delete this category...
     return parent::delete();
 }
Ejemplo n.º 4
0
 public static function getKeyColumns(&$newData, $occur_date, $postData)
 {
     $attributes = parent::getKeyColumns($newData, $occur_date, $postData);
     if (array_key_exists('isAdding', $newData) && array_key_exists('Tank', $postData)) {
         $newData['TANK_ID'] = $postData['Tank'];
     }
     return $attributes;
 }
Ejemplo n.º 5
0
 public function checkAndSave(&$values)
 {
     if (!isset($values['DOCUMENT_SET_DATA_ID']) || !$values['DOCUMENT_SET_DATA_ID'] || empty($values['DOCUMENT_SET_DATA_ID'])) {
         return null;
     }
     if (!isset($values['CONTACT_ID']) || !$values['CONTACT_ID'] || empty($values['CONTACT_ID'])) {
         return null;
     }
     if (isset($values['ORGINAL_ID']) && (empty($values['ORGINAL_ID']) || $values['ORGINAL_ID'] == " ")) {
         $values['ORGINAL_ID'] = NULL;
     }
     if (isset($values['NUMBER_COPY']) && (empty($values['NUMBER_COPY']) || $values['NUMBER_COPY'] == " ")) {
         $values['NUMBER_COPY'] = NULL;
     }
     return parent::checkAndSave($values);
 }
Ejemplo n.º 6
0
 public static function deleteWithConfig($mdlData)
 {
     $valuesIds = array_values($mdlData);
     \App\Models\PdDocumentSetContactData::whereIn('DOCUMENT_SET_DATA_ID', $valuesIds)->delete();
     parent::deleteWithConfig($mdlData);
 }