Code Duplication    Length = 44-46 lines in 4 locations

system/modules/Users/models/Group.php 1 location

@@ 12-57 (lines=46) @@
9
 */
10
namespace Users;
11
12
class Group extends \Model
13
{
14
    public static $objectName = 'Группа пользователей';
15
    public static $labels = [
16
        'name' => 'Название',
17
        'user' => 'Пользователи',
18
        'role' => 'Роли'
19
    ];
20
    public static $cols = [
21
        'name' => ['type' => 'text'],
22
        'user' => ['type' => 'select', 'source' => 'relation', 'relation' => 'users'],
23
        'role' => ['type' => 'select', 'source' => 'relation', 'relation' => 'roles'],
24
    ];
25
    public static $dataManagers = [
26
        'manager' => [
27
            'name' => 'Группы пользователей',
28
            'cols' => [
29
                'name', 'role', 'user'
30
            ]
31
        ]
32
    ];
33
    public static $forms = [
34
        'manager' => [
35
            'map' => [
36
                ['name']
37
            ]
38
        ]
39
    ];
40
41
    public static function relations()
42
    {
43
        return [
44
            'roles' => [
45
                'type' => 'many',
46
                'model' => 'Users\Role',
47
                'col' => 'group_id'
48
            ],
49
            'users' => [
50
                'type' => 'many',
51
                'model' => 'Users\User',
52
                'col' => 'group_id'
53
            ]
54
        ];
55
    }
56
57
}
58

system/modules/Migrations/models/Log/Event.php 1 location

@@ 14-57 (lines=44) @@
11
12
namespace Migrations\Log;
13
14
class Event extends \Model
15
{
16
    public static $objectName = 'Событие истории миграции';
17
    public static $labels = [
18
        'type' => 'Тип',
19
        'info' => 'Информация',
20
        'date_create' => 'Дата события'
21
    ];
22
    public static $cols = [
23
        'type' => ['type' => 'text'],
24
        'info' => ['type' => 'textarea'],
25
        'log_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'log'],
26
        'map_path_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'path'],
27
        'date_create' => ['type' => 'dateTime'],
28
    ];
29
    public static $dataManagers = [
30
        'manager' => [
31
            'cols' => ['type', 'info', 'date_create']
32
        ]
33
    ];
34
    public static $forms = [
35
        'manager' => [
36
            'map' => [
37
                ['type'],
38
                ['info'],
39
            ]
40
        ]
41
    ];
42
43
    public static function relations()
44
    {
45
        return [
46
            'log' => [
47
                'col' => 'log_id',
48
                'model' => 'Migrations\Log'
49
            ],
50
            'path' => [
51
                'col' => 'map_path_id',
52
                'model' => 'Migrations\Migrations\Map\Path'
53
            ]
54
        ];
55
    }
56
57
}
58

system/modules/Users/models/Activity.php 1 location

@@ 14-59 (lines=46) @@
11
12
namespace Users;
13
14
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
        'date_create' => ['type' => 'dateTime'],
27
    ];
28
    public static $dataManagers = [
29
        'manager' => [
30
            'name' => 'Activity',
31
            'cols' => [
32
                'text', 'user_id', 'category_id', 'date_create',
33
            ]
34
        ]
35
    ];
36
    public static $forms = [
37
        'manager' => [
38
            'map' => [
39
                ['text'],
40
                ['user_id', 'category_id']
41
            ]
42
        ]
43
    ];
44
45
    public static function relations()
46
    {
47
        return [
48
            'user' => [
49
                'model' => 'Users\User',
50
                'col' => 'user_id'
51
            ],
52
            'category' => [
53
                'model' => 'Users\Activity\Category',
54
                'col' => 'category_id'
55
            ],
56
        ];
57
    }
58
59
}
60

system/modules/Ecommerce/models/Cart/Discount.php 1 location

@@ 14-57 (lines=44) @@
11
12
namespace Ecommerce\Cart;
13
14
class Discount extends \Model
15
{
16
    public static $objectName = 'Скидка корзины';
17
    public static $cols = [
18
        'cart_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'cart'],
19
        'discount_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'discount'],
20
        'auto' => ['type' => 'bool'],
21
        'group' => ['type' => 'text'],
22
    ];
23
    public static $labels = [
24
        'cart_id' => 'Корзина',
25
        'discount_id' => 'Скидки',
26
        'auto' => 'Добавлена автоматически',
27
        'group' => 'Группа',
28
    ];
29
    public static $dataManagers = [
30
        'manager' => [
31
            'cols' => ['discount_id', 'auto', 'group']
32
        ]
33
    ];
34
    public static $forms = [
35
        'manager' => [
36
            'map' => [
37
                ['cart_id', 'discount_id'],
38
                ['auto', 'group']
39
            ]
40
        ]
41
    ];
42
43
    public static function relations()
44
    {
45
        return [
46
            'cart' => [
47
                'model' => 'Ecommerce\Cart',
48
                'col' => 'cart_id'
49
            ],
50
            'discount' => [
51
                'model' => 'Ecommerce\Discount',
52
                'col' => 'discount_id'
53
            ]
54
        ];
55
    }
56
57
}
58