1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Delivery user info |
5
|
|
|
* @author Alexey Krupskiy <[email protected]> |
6
|
|
|
* @link http://inji.ru/ |
7
|
|
|
* @copyright 2016 Alexey Krupskiy |
8
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Ecommerce\Cart; |
12
|
|
|
|
13
|
|
View Code Duplication |
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
|
|
|
|