Completed
Pull Request — master (#3)
by
unknown
05:51
created

Activity::relations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 13
loc 13
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/**
4
 * Role
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 Users;
13
14 View Code Duplication
class Activity extends \Model
15
{
16
    public static $objectName = 'Activity';
17
    public static $labels = [
18
        'text' => 'Текст',
19
        'user_id' => 'Пользователь',
20
        'category_id' => 'Категория',
21
    ];
22
    public static $cols = [
23
        'text' => ['type' => 'text'],
24
        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
25
        'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'],
26
    ];
27
    public static $dataManagers = [
28
        'manager' => [
29
            'name' => 'Activity',
30
            'cols' => [
31
                'text', 'user_id', 'category_id', 'date_create',
32
            ]
33
        ]
34
    ];
35
    public static $forms = [
36
        'manager' => [
37
            'map' => [
38
                ['text'],
39
                ['user_id', 'category_id']
40
            ]
41
        ]
42
    ];
43
44
    public static function relations()
45
    {
46
        return [
47
            'user' => [
48
                'model' => 'Users\User',
49
                'col' => 'user_id'
50
            ],
51
            'category' => [
52
                'model' => 'Users\Activity\Category',
53
                'col' => 'category_id'
54
            ],
55
        ];
56
    }
57
58
}
59