Se agregan los campos por segmento

This commit is contained in:
2020-06-03 21:59:11 -04:00
parent 2d2eccb600
commit 080ed4553e
14 changed files with 486 additions and 174 deletions

View File

@ -114,7 +114,15 @@ class Model {
return $data;
}
protected function fillObject($data): BaseModel {
$obj = new $this->class;
$class = $this->class;
if (strpos($class, 'Producto') !== false) {
$segmento = str_replace(' ', '', $data->segmento);
$class = implode("\\", [
$class . 's',
rtrim($segmento, 's')
]);
}
$obj = new $class;
$obj->map($data);
$obj->setFactory($this);
$obj->setImageFolder($this->image_folder);
@ -139,6 +147,13 @@ class Model {
}
public function create(string $class, $data) {
if (strpos($class, 'Producto') !== false) {
$segmento = str_replace(' ', '', $data->segmento);
$class = implode("\\", [
$class . 's',
rtrim($segmento, 's')
]);
}
$obj = new $class;
$obj->map($data);
$obj->setFactory($this);