| @@ 13-81 (lines=69) @@ | ||
| 10 | ||
| 11 | namespace Ecommerce\Cart; |
|
| 12 | ||
| 13 | class DeliveryInfo extends \Model { |
|
| 14 | ||
| 15 | public static $objectName = 'Информация о доставке'; |
|
| 16 | public static $labels = [ |
|
| 17 | 'name' => 'Название', |
|
| 18 | 'cart_id' => 'Корзина', |
|
| 19 | 'delivery_field_id' => 'Поле', |
|
| 20 | 'value' => 'Значение', |
|
| 21 | ]; |
|
| 22 | public static $cols = [ |
|
| 23 | //Основные параметры |
|
| 24 | 'name' => ['type' => 'text'], |
|
| 25 | 'cart_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'cart'], |
|
| 26 | 'delivery_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'], |
|
| 27 | 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType'], |
|
| 28 | //Системные |
|
| 29 | 'date_create' => ['type' => 'dateTime'], |
|
| 30 | ]; |
|
| 31 | public static $forms = [ |
|
| 32 | 'manager' => [ |
|
| 33 | 'map' => [ |
|
| 34 | ['name', 'value'], |
|
| 35 | ['delivery_field_id', 'cart_id'], |
|
| 36 | ] |
|
| 37 | ] |
|
| 38 | ]; |
|
| 39 | public static $dataManagers = [ |
|
| 40 | 'manager' => [ |
|
| 41 | 'cols' => [ |
|
| 42 | 'name', |
|
| 43 | 'value' |
|
| 44 | ] |
|
| 45 | ] |
|
| 46 | ]; |
|
| 47 | ||
| 48 | public static function relations() { |
|
| 49 | return [ |
|
| 50 | 'field' => [ |
|
| 51 | 'model' => 'Ecommerce\Delivery\Field', |
|
| 52 | 'col' => 'delivery_field_id' |
|
| 53 | ], |
|
| 54 | 'cart' => [ |
|
| 55 | 'model' => 'Ecommerce\Cart', |
|
| 56 | 'col' => 'cart_id' |
|
| 57 | ], |
|
| 58 | ]; |
|
| 59 | } |
|
| 60 | ||
| 61 | public function realType() { |
|
| 62 | if ($this->field && $this->field->type) { |
|
| 63 | $type = $this->field->type; |
|
| 64 | ||
| 65 | if ($type == 'select') { |
|
| 66 | return [ |
|
| 67 | 'type' => 'select', |
|
| 68 | 'source' => 'relation', |
|
| 69 | 'relation' => 'field:fieldItems', |
|
| 70 | ]; |
|
| 71 | } elseif ($type === 'autocomplete') { |
|
| 72 | return [ |
|
| 73 | 'type' => 'autocomplete', |
|
| 74 | 'options' => json_decode($this->field->options, true) |
|
| 75 | ]; |
|
| 76 | } |
|
| 77 | return $type; |
|
| 78 | } |
|
| 79 | return 'text'; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| @@ 14-81 (lines=68) @@ | ||
| 11 | ||
| 12 | namespace Ecommerce\Cart; |
|
| 13 | ||
| 14 | class Info extends \Model { |
|
| 15 | ||
| 16 | public static $objectName = 'Информация'; |
|
| 17 | public static $labels = [ |
|
| 18 | 'name' => 'Название', |
|
| 19 | 'value' => 'Значение', |
|
| 20 | 'useradds_field_id' => 'Поле', |
|
| 21 | 'cart_id' => 'Корзина' |
|
| 22 | ]; |
|
| 23 | public static $cols = [ |
|
| 24 | 'name' => ['type' => 'text'], |
|
| 25 | 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType'], |
|
| 26 | 'cart_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'cart'], |
|
| 27 | 'useradds_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'], |
|
| 28 | //Системные параметры |
|
| 29 | 'date_create' => ['type' => 'dateTime'], |
|
| 30 | ]; |
|
| 31 | public static $dataManagers = [ |
|
| 32 | 'manager' => [ |
|
| 33 | 'cols' => [ |
|
| 34 | 'name', |
|
| 35 | 'value', |
|
| 36 | ], |
|
| 37 | ], |
|
| 38 | ]; |
|
| 39 | public static $forms = [ |
|
| 40 | 'manager' => [ |
|
| 41 | 'map' => [ |
|
| 42 | ['name', 'value'], |
|
| 43 | ['useradds_field_id', 'cart_id'], |
|
| 44 | ] |
|
| 45 | ] |
|
| 46 | ]; |
|
| 47 | ||
| 48 | public static function relations() { |
|
| 49 | return [ |
|
| 50 | 'cart' => [ |
|
| 51 | 'model' => 'Ecommerce\Cart', |
|
| 52 | 'col' => 'cart_id' |
|
| 53 | ], |
|
| 54 | 'field' => [ |
|
| 55 | 'model' => 'Ecommerce\UserAdds\Field', |
|
| 56 | 'col' => 'useradds_field_id' |
|
| 57 | ] |
|
| 58 | ]; |
|
| 59 | } |
|
| 60 | ||
| 61 | public function realType() { |
|
| 62 | if ($this->field && $this->field->type) { |
|
| 63 | $type = $this->field->type; |
|
| 64 | ||
| 65 | if ($type == 'select') { |
|
| 66 | return [ |
|
| 67 | 'type' => 'select', |
|
| 68 | 'source' => 'relation', |
|
| 69 | 'relation' => 'field:fieldItems', |
|
| 70 | ]; |
|
| 71 | } elseif ($type === 'autocomplete') { |
|
| 72 | return [ |
|
| 73 | 'type' => 'autocomplete', |
|
| 74 | 'options' => json_decode($this->field->options, true) |
|
| 75 | ]; |
|
| 76 | } |
|
| 77 | return $type; |
|
| 78 | } |
|
| 79 | return 'text'; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||