1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Item offer price |
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\Item\Offer; |
13
|
|
|
|
14
|
|
|
use Users\User; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Price |
18
|
|
|
* |
19
|
|
|
* @property int $id |
20
|
|
|
* @property int $item_offer_id |
21
|
|
|
* @property int $item_offer_price_type_id |
22
|
|
|
* @property string $name |
23
|
|
|
* @property number $price |
24
|
|
|
* @property int $currency_id |
25
|
|
|
* @property int $weight |
26
|
|
|
* @property string $date_create |
27
|
|
|
* |
28
|
|
|
* @property-read \Ecommerce\Item\Offer $offer |
29
|
|
|
* @property-read \Ecommerce\Item\Offer\Price\Type $type |
30
|
|
|
* @property-read \Money\Currency $currency |
31
|
|
|
* |
32
|
|
|
* @method \Ecommerce\Item\Offer\Price\Type type($options) |
33
|
|
|
* @method \Ecommerce\Item\Offer offer($options) |
34
|
|
|
* @method \Money\Currency currency($options) |
35
|
|
|
*/ |
36
|
|
|
class Price extends \Model { |
37
|
|
|
|
38
|
|
|
public static $objectName = 'Цена'; |
39
|
|
|
public static $cols = [ |
40
|
|
|
//Основные параметры |
41
|
|
|
'item_offer_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'offer'], |
42
|
|
|
'item_offer_price_type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'], |
43
|
|
|
'name' => ['type' => 'text'], |
44
|
|
|
'price' => ['type' => 'decimal'], |
45
|
|
|
'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'], |
46
|
|
|
//Системные |
47
|
|
|
'weight' => ['type' => 'text'], |
48
|
|
|
'date_create' => ['type' => 'dateTime'], |
49
|
|
|
]; |
50
|
|
|
public static $labels = [ |
51
|
|
|
'price' => 'Цена', |
52
|
|
|
'item_offer_price_type_id' => 'Тип цены', |
53
|
|
|
'item_offer_id' => 'Товар', |
54
|
|
|
'currency_id' => 'Валюта', |
55
|
|
|
]; |
56
|
|
|
public static $dataManagers = [ |
57
|
|
|
'manager' => [ |
58
|
|
|
'name' => 'Цены', |
59
|
|
|
'cols' => [ |
60
|
|
|
'item_offer_price_type_id', |
61
|
|
|
'price', |
62
|
|
|
'currency_id', |
63
|
|
|
] |
64
|
|
|
], |
65
|
|
|
]; |
66
|
|
|
public static $forms = [ |
67
|
|
|
'manager' => [ |
68
|
|
|
'map' => [ |
69
|
|
|
['price', 'currency_id'], |
70
|
|
|
['item_offer_price_type_id'] |
71
|
|
|
] |
72
|
|
|
] |
73
|
|
|
]; |
74
|
|
|
|
75
|
|
|
public function name() { |
76
|
|
|
$name = $this->offer->name(); |
77
|
|
|
if ($this->type) { |
78
|
|
|
$name .= ' - ' . $this->type->name(); |
79
|
|
|
} |
80
|
|
|
$name .= ': ' . $this->price; |
81
|
|
|
if ($this->currency) { |
82
|
|
|
$name .= ' ' . $this->currency->name(); |
83
|
|
|
} |
84
|
|
|
return $name; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public static function relations() { |
88
|
|
|
return [ |
89
|
|
|
'offer' => [ |
90
|
|
|
'model' => 'Ecommerce\Item\Offer', |
91
|
|
|
'col' => 'item_offer_id' |
92
|
|
|
], |
93
|
|
|
'type' => [ |
94
|
|
|
'model' => 'Ecommerce\Item\Offer\Price\Type', |
95
|
|
|
'col' => 'item_offer_price_type_id' |
96
|
|
|
], |
97
|
|
|
'currency' => [ |
98
|
|
|
'model' => 'Money\Currency', |
99
|
|
|
'col' => 'currency_id' |
100
|
|
|
], |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|