public function getExtraOptions($productionFilterGroup, $model, $source = null) { if (is_string($source)) { $extraSource = $productionFilterGroup[$source]; // $currentId = $extraSource['currentId']; $entry = ProductionGroupComposer::getCurrentSelect($extraSource['collection']); $eModel = $entry->CODE; $tableName = strtolower($eModel); $mdlName = \Helper::camelize($tableName, '_'); // $mdl = 'App\Models\\' . $mdlName; // $eCollection = $mdl::getEntries ( $currentFacility->ID ); return [$source => ['name' => $mdlName, 'id' => $entry->ID, 'object' => $entry]]; } return null; }
public function getCodes(Request $request) { $options = $request->only('type', 'value', 'dependences', 'extra'); $bunde = $options['extra']; $type = $options['type']; if ($type == 'date_end' || $type == 'date_begin') { $unit = new CustomizeDateCollection($type, $options['value']); } else { $mdl = 'App\\Models\\' . $type; $unit = $mdl::find($options['value']); } $originUnit = $unit; $results = []; $currentUnits = [$type => $unit]; foreach ($options['dependences'] as $model) { $modelName = $model; $currentId = null; $sourceUnit = $unit; $isAdd = true; if (is_array($model)) { if (array_key_exists("source", $model)) { $currentSourceName = $model["source"]; $sourceUnit = array_key_exists($currentSourceName, $currentUnits) ? $currentUnits[$currentSourceName] : $originUnit; } else { $sourceUnit = $originUnit; } $modelName = $model["name"]; $isAdd = !array_key_exists("independent", $model) || !$model["independent"]; } if ($sourceUnit != null) { $rs = ProductionGroupComposer::initExtraDependence($results, $model, $sourceUnit, $bunde); $eCollection = $rs['collection']; $modelName = $rs['model']; $currentId = $rs['currentId']; } else { break; } if (is_string($model) && array_key_exists($model, config("constants.subProductFilterMapping")) && array_key_exists('default', config("constants.subProductFilterMapping")[$model])) { $eCollection[] = config("constants.subProductFilterMapping")[$model]['default']; } $unit = ProductionGroupComposer::getCurrentSelect($eCollection, $currentId); $currentUnits[$modelName] = $unit; $filterArray = ProductionGroupComposer::getFilterArray($modelName, $eCollection, $unit); if ($isAdd) { $results[] = $filterArray; } } return response($results, 200)->header('Content-Type', 'application/json'); }