Completed
Push — master ( 8717df...fdbe7f )
by Alexey
05:44
created

Warehouse::relations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 13
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/**
4
 * Item offer warehouse
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
class Warehouse extends \Model
15
{
16
    public static $objectName = 'Товар на складе';
17
    public static $labels = [
18
        'count' => 'Количество',
19
        'warehouse_id' => 'Склад',
20
        'item_offer_id' => 'Торговое предложение',
21
    ];
22
    public static $cols = [
23
        //Основные параметры
24
        'warehouse_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'warehouse'],
25
        'item_offer_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'offer'],
26
        'count' => ['type' => 'text'],
27
        //Системные
28
        'date_create' => ['type' => 'dateTime'],
29
    ];
30
    public static $dataManagers = [
31
        'manager' => [
32
            'name' => 'Складской учет',
33
            'cols' => [
34
                'warehouse_id',
35
                'count',
36
            ],
37
        ],
38
    ];
39
    public static $forms = [
40
        'manager' => [
41
            'map' => [
42
                ['item_offer_id', 'warehouse_id'],
43
                ['count'],
44
            ]
45
    ]];
46
47
    public static function indexes()
48
    {
49
        return [
50
            'ecommerce_warehousePriceIndex' => [
51
                'type' => 'INDEX',
52
                'cols' => [
53
                    'item_offer_warehouse_item_offer_id'
54
                ]
55
            ]
56
        ];
57
    }
58
59
    public static function relations()
60
    {
61
        return [
62
            'warehouse' => [
63
                'model' => 'Ecommerce\Warehouse',
64
                'col' => 'warehouse_id'
65
            ],
66
            'offer' => [
67
                'model' => 'Ecommerce\Item\Offer',
68
                'col' => 'item_offer_id'
69
            ],
70
        ];
71
    }
72
73
}
74