| @@ 8-48 (lines=41) @@ | ||
| 5 | * Class Category |
|
| 6 | * @package pastuhov\ymlcatalog\models |
|
| 7 | */ |
|
| 8 | class Category extends BaseModel |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @inheritdoc |
|
| 12 | */ |
|
| 13 | public static $tag = 'category'; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @inheritdoc |
|
| 17 | */ |
|
| 18 | public static $tagProperties = [ |
|
| 19 | 'id', |
|
| 20 | 'parentId', |
|
| 21 | ]; |
|
| 22 | ||
| 23 | public $name; |
|
| 24 | public $parentId; |
|
| 25 | public $id; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @inheritdoc |
|
| 29 | */ |
|
| 30 | public function rules() |
|
| 31 | { |
|
| 32 | return [ |
|
| 33 | [ |
|
| 34 | ['id', 'name'], |
|
| 35 | 'required', |
|
| 36 | ], |
|
| 37 | [ |
|
| 38 | ['name'], |
|
| 39 | 'string', |
|
| 40 | 'max' => 255, |
|
| 41 | ], |
|
| 42 | [ |
|
| 43 | ['id', 'parentId'], |
|
| 44 | 'integer', |
|
| 45 | ], |
|
| 46 | ]; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 10-57 (lines=48) @@ | ||
| 7 | * Модель опции условий доставки - тега option в секции delivery-option |
|
| 8 | * @package pastuhov\ymlcatalog\models |
|
| 9 | */ |
|
| 10 | class DeliveryOption extends BaseModel |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @inheritdoc |
|
| 14 | */ |
|
| 15 | public static $tag = 'option'; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @inheritdoc |
|
| 19 | */ |
|
| 20 | public static $tagProperties = [ |
|
| 21 | 'cost', |
|
| 22 | 'days', |
|
| 23 | ]; |
|
| 24 | ||
| 25 | /** @var int Стоимость доставки в рублях. */ |
|
| 26 | public $cost; |
|
| 27 | ||
| 28 | /** @var string Срок доставки в рабочих днях. */ |
|
| 29 | public $days; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @inheritdoc |
|
| 33 | */ |
|
| 34 | public function rules() |
|
| 35 | { |
|
| 36 | return [ |
|
| 37 | [ |
|
| 38 | ['cost', 'days'], |
|
| 39 | 'required', |
|
| 40 | ], |
|
| 41 | [ |
|
| 42 | ['cost'], |
|
| 43 | 'integer', |
|
| 44 | ], |
|
| 45 | [ |
|
| 46 | ['days'], |
|
| 47 | 'string', |
|
| 48 | 'max' => 5, |
|
| 49 | ], |
|
| 50 | ]; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @inheritdoc |
|
| 55 | */ |
|
| 56 | protected function getYmlBody() |
|
| 57 | { |
|
| 58 | return null; |
|
| 59 | } |
|
| 60 | } |
|