Completed
Push — master ( 594f71...a14e49 )
by Alexey
05:31
created

City::relations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
/**
4
 * City Model
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2016 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Geography;
13
14
class City extends \Model
15
{
16
    public static $cur = null;
17
    public static $objectName = 'Город';
18
    public static $labels = [
19
        'name' => 'Название',
20
        'alias' => 'Алиас',
21
        'default' => 'По умолчанию',
22
        'country_id' => 'Страна',
23
        'data' => 'Данные',
24
        'date_create' => 'Дата создания',
25
    ];
26
    public static $cols = [
27
        'name' => ['type' => 'text'],
28
        'alias' => ['type' => 'text'],
29
        'default' => ['type' => 'bool'],
30
        'country_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'country'],
31
        'data' => ['type' => 'dataManager', 'relation' => 'datas'],
32
        'date_create' => ['type' => 'dateTime'],
33
    ];
34
    public static $dataManagers = [
35
        'manager' => [
36
            'cols' => ['name', 'alias', 'default', 'data', 'date_create']
37
        ]
38
    ];
39
    public static $forms = [
40
        'manager' => [
41
            'map' => [
42
                ['name', 'alias'],
43
                ['default', 'country_id'],
44
            ]
45
        ]
46
    ];
47
48
    public static function relations()
49
    {
50
        return [
51
            'country' => [
52
                'model' => 'Geography\Country',
53
                'col' => 'country_id'
54
            ],
55
            'datas' => [
56
                'type' => 'many',
57
                'model' => 'Geography\City\Data',
58
                'col' => 'city_id',
59
                'resultKey' => 'code'
60
            ]
61
        ];
62
    }
63
64
}
65