| @@ 14-98 (lines=85) @@ | ||
| 11 | ||
| 12 | namespace Ecommerce\Item\Offer; |
|
| 13 | ||
| 14 | class Option extends \Model |
|
| 15 | { |
|
| 16 | public static $objectName = 'Свойство предложения'; |
|
| 17 | public static $cols = [ |
|
| 18 | //Основные параметры |
|
| 19 | 'name' => ['type' => 'text'], |
|
| 20 | 'filter_name' => ['type' => 'text'], |
|
| 21 | 'image_file_id' => ['type' => 'image'], |
|
| 22 | 'code' => ['type' => 'text'], |
|
| 23 | 'type' => ['type' => 'text'], |
|
| 24 | 'postfix' => ['type' => 'text'], |
|
| 25 | 'default_val' => ['type' => 'text'], |
|
| 26 | 'view' => ['type' => 'bool'], |
|
| 27 | 'searchable' => ['type' => 'bool'], |
|
| 28 | //Системные |
|
| 29 | 'weight' => ['type' => 'number'], |
|
| 30 | 'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'], |
|
| 31 | 'advance' => ['type' => 'text'], |
|
| 32 | 'date_create' => ['type' => 'dateTime'], |
|
| 33 | //Менеджеры |
|
| 34 | 'item' => ['type' => 'dataManager', 'relation' => 'items'], |
|
| 35 | ]; |
|
| 36 | public static $labels = [ |
|
| 37 | 'name' => 'Название', |
|
| 38 | 'filter_name' => 'Название в фильтре', |
|
| 39 | 'image_file_id' => 'Иконка', |
|
| 40 | 'code' => 'Код', |
|
| 41 | 'type' => 'Тип', |
|
| 42 | 'postfix' => 'Постфикс', |
|
| 43 | 'default_val' => 'Значение по умолчанию', |
|
| 44 | 'view' => 'Отображается', |
|
| 45 | 'searchable' => 'Используется при поиске', |
|
| 46 | 'weight' => 'Вес сортировки', |
|
| 47 | 'advance' => 'Дополнительные параметры', |
|
| 48 | 'user_id' => 'Создатель', |
|
| 49 | 'date_create' => 'Дата создания', |
|
| 50 | 'item' => 'Значения для списка' |
|
| 51 | ]; |
|
| 52 | public static $dataManagers = [ |
|
| 53 | 'manager' => [ |
|
| 54 | 'name' => 'Свойства предложения', |
|
| 55 | 'cols' => [ |
|
| 56 | 'name', 'code', 'type', 'item', 'view', 'searchable', 'user_id', 'date_create' |
|
| 57 | ] |
|
| 58 | ] |
|
| 59 | ]; |
|
| 60 | public static $forms = [ |
|
| 61 | 'manager' => [ |
|
| 62 | 'map' => [ |
|
| 63 | ['name', 'filter_name'], |
|
| 64 | ['code', 'type', 'image_file_id'], |
|
| 65 | ['default_val', 'postfix'], |
|
| 66 | ['view', 'searchable'], |
|
| 67 | ['item'] |
|
| 68 | ] |
|
| 69 | ] |
|
| 70 | ]; |
|
| 71 | ||
| 72 | public static function relations() |
|
| 73 | { |
|
| 74 | return [ |
|
| 75 | 'user' => [ |
|
| 76 | 'model' => 'Users\User', |
|
| 77 | 'col' => 'user_id' |
|
| 78 | ], |
|
| 79 | 'items' => [ |
|
| 80 | 'type' => 'many', |
|
| 81 | 'model' => 'Ecommerce\Item\Offer\Option\Item', |
|
| 82 | 'col' => 'item_offer_option_id' |
|
| 83 | ], |
|
| 84 | 'image' => [ |
|
| 85 | 'model' => 'Files\File', |
|
| 86 | 'col' => 'image_file_id' |
|
| 87 | ], |
|
| 88 | ]; |
|
| 89 | } |
|
| 90 | ||
| 91 | public function beforeSave() |
|
| 92 | { |
|
| 93 | if (!isset($this->id)) { |
|
| 94 | $this->user_id = \Users\User::$cur->id; |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| 98 | } |
|
| 99 | ||
| @@ 14-98 (lines=85) @@ | ||
| 11 | ||
| 12 | namespace Ecommerce\Item; |
|
| 13 | ||
| 14 | class Option extends \Model |
|
| 15 | { |
|
| 16 | public static $objectName = 'Свойство'; |
|
| 17 | public static $cols = [ |
|
| 18 | //Основные параметры |
|
| 19 | 'name' => ['type' => 'text'], |
|
| 20 | 'filter_name' => ['type' => 'text'], |
|
| 21 | 'image_file_id' => ['type' => 'image'], |
|
| 22 | 'code' => ['type' => 'text'], |
|
| 23 | 'type' => ['type' => 'text'], |
|
| 24 | 'postfix' => ['type' => 'text'], |
|
| 25 | 'default_val' => ['type' => 'text'], |
|
| 26 | 'view' => ['type' => 'bool'], |
|
| 27 | 'searchable' => ['type' => 'bool'], |
|
| 28 | //Системные |
|
| 29 | 'weight' => ['type' => 'number'], |
|
| 30 | 'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'], |
|
| 31 | 'advance' => ['type' => 'text'], |
|
| 32 | 'date_create' => ['type' => 'dateTime'], |
|
| 33 | //Менеджеры |
|
| 34 | 'item' => ['type' => 'dataManager', 'relation' => 'items'], |
|
| 35 | ]; |
|
| 36 | public static $labels = [ |
|
| 37 | 'name' => 'Название', |
|
| 38 | 'filter_name' => 'Название в фильтре', |
|
| 39 | 'image_file_id' => 'Иконка', |
|
| 40 | 'code' => 'Код', |
|
| 41 | 'type' => 'Тип', |
|
| 42 | 'postfix' => 'Постфикс', |
|
| 43 | 'default_val' => 'Значение по умолчанию', |
|
| 44 | 'view' => 'Отображается', |
|
| 45 | 'searchable' => 'Используется при поиске', |
|
| 46 | 'weight' => 'Вес сортировки', |
|
| 47 | 'advance' => 'Дополнительные параметры', |
|
| 48 | 'user_id' => 'Создатель', |
|
| 49 | 'date_create' => 'Дата создания', |
|
| 50 | 'item' => 'Значения для списка' |
|
| 51 | ]; |
|
| 52 | public static $dataManagers = [ |
|
| 53 | 'manager' => [ |
|
| 54 | 'name' => 'Свойства товаров', |
|
| 55 | 'cols' => [ |
|
| 56 | 'name', 'code', 'type', 'item', 'view', 'searchable', 'user_id', 'date_create' |
|
| 57 | ] |
|
| 58 | ] |
|
| 59 | ]; |
|
| 60 | public static $forms = [ |
|
| 61 | 'manager' => [ |
|
| 62 | 'map' => [ |
|
| 63 | ['name', 'filter_name'], |
|
| 64 | ['code', 'type', 'image_file_id'], |
|
| 65 | ['default_val', 'postfix'], |
|
| 66 | ['view', 'searchable'], |
|
| 67 | ['item'] |
|
| 68 | ] |
|
| 69 | ] |
|
| 70 | ]; |
|
| 71 | ||
| 72 | public static function relations() |
|
| 73 | { |
|
| 74 | return [ |
|
| 75 | 'user' => [ |
|
| 76 | 'model' => 'Users\User', |
|
| 77 | 'col' => 'user_id' |
|
| 78 | ], |
|
| 79 | 'items' => [ |
|
| 80 | 'type' => 'many', |
|
| 81 | 'model' => 'Ecommerce\Item\Option\Item', |
|
| 82 | 'col' => 'item_option_id' |
|
| 83 | ], |
|
| 84 | 'image' => [ |
|
| 85 | 'model' => 'Files\File', |
|
| 86 | 'col' => 'image_file_id' |
|
| 87 | ], |
|
| 88 | ]; |
|
| 89 | } |
|
| 90 | ||
| 91 | public function beforeSave() |
|
| 92 | { |
|
| 93 | if (!isset($this->id)) { |
|
| 94 | $this->user_id = \Users\User::$cur->id; |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| 98 | } |
|
| 99 | ||