Test Failed
Push — master ( 455e4b...89dfd0 )
by Alexey
07:06 queued 02:50
created

Delivery   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B relations() 0 26 1
1
<?php
2
3
/**
4
 * Delivery
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Ecommerce;
13
/**
14
 * Class Delivery
15
 *
16
 * @property int $id
17
 * @property string $name
18
 * @property string $price_type
19
 * @property number $price
20
 * @property int $currency_id
21
 * @property string $price_text
22
 * @property number $max_cart_price
23
 * @property int $icon_file_id
24
 * @property string $info
25
 * @property bool $disabled
26
 * @property number $weight
27
 * @property string $date_create
28
 * @property \Files\File $icon
29
 * @property \Money\Currency $currency
30
 * @property \Ecommerce\Delivery\Field[] $fields
31
 * @property \Ecommerce\Delivery\Price[] $prices
32
 */
33
class Delivery extends \Model {
34
35
    public static $objectName = 'Доставка';
36
    public static $cols = [
37
        //Основные параметры
38
        'name' => ['type' => 'text'],
39
        'delivery_provider_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'provider'],
40
        'price' => ['type' => 'decimal'],
41
        'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'],
42
        'price_text' => ['type' => 'textarea'],
43
        'max_cart_price' => ['type' => 'decimal'],
44
        'icon_file_id' => ['type' => 'image'],
45
        'info' => ['type' => 'html'],
46
        'disabled' => ['type' => 'bool'],
47
        //Системные
48
        'weight' => ['type' => 'number'],
49
        'date_create' => ['type' => 'dateTime'],
50
        //Менеджеры
51
        'field' => ['type' => 'dataManager', 'relation' => 'fields'],
52
        'priceChanger' => ['type' => 'dataManager', 'relation' => 'prices']
53
    ];
54
    public static $labels = [
55
        'name' => 'Название',
56
        'price_type' => 'Тип расчета стоимости',
57
        'price' => 'Стоимость',
58
        'price_text' => 'Текстовое описание стоимости (отображается вместо цены)',
59
        'max_cart_price' => 'Басплатно при',
60
        'icon_file_id' => 'Иконка',
61
        'currency_id' => 'Валюта',
62
        'info' => 'Дополнительная информация',
63
        'priceChanger' => 'Градация стоимости',
64
        'field' => 'Поля',
65
        'disabled' => 'Отключено',
66
    ];
67
    public static $dataManagers = [
68
        'manager' => [
69
            'name' => 'Варианты доставки',
70
            'cols' => [
71
                'name',
72
                'delivery_provider_id',
73
                'price',
74
                'currency_id',
75
                'max_cart_price',
76
                'disabled',
77
                'field',
78
                'priceChanger',
79
            ],
80
            'sortMode' => true
81
        ],
82
    ];
83
    public static $forms = [
84
        'manager' => [
85
            'map' => [
86
                ['name','delivery_provider_id', 'disabled'],
87
                ['price', 'currency_id'],
88
                ['max_cart_price', 'icon_file_id'],
89
                ['price_text'],
90
                ['info'],
91
                ['priceChanger'],
92
                ['field']
93
            ]
94
        ]];
95
96
    public static function relations() {
97
        return [
98
            'icon' => [
99
                'model' => 'Files\File',
100
                'col' => 'icon_file_id'
101
            ],
102
            'currency' => [
103
                'model' => 'Money\Currency',
104
                'col' => 'currency_id'
105
            ],
106
            'fields' => [
107
                'type' => 'relModel',
108
                'model' => 'Ecommerce\Delivery\Field',
109
                'relModel' => 'Ecommerce\Delivery\DeliveryFieldLink'
110
            ],
111
            'prices' => [
112
                'type' => 'many',
113
                'model' => 'Ecommerce\Delivery\Price',
114
                'col' => 'delivery_id'
115
            ],
116
            'provider' => [
117
                'model' => 'Ecommerce\Delivery\Provider',
118
                'col' => 'delivery_provider_id'
119
            ]
120
        ];
121
    }
122
123
}
124