Code Duplication    Length = 21-22 lines in 5 locations

system/modules/Callbacks/models/Category.php 1 location

@@ 46-67 (lines=22) @@
43
        ]
44
    ];
45
46
    public static function relations() {
47
        return [
48
            'callbacks' => [
49
                'type' => 'many',
50
                'model' => 'Callbacks\Callback',
51
                'col' => 'category_id',
52
            ],
53
            'parent' => [
54
                'model' => 'Callbacks\Category',
55
                'col' => 'parent_id'
56
            ],
57
            'image' => [
58
                'model' => 'Files\File',
59
                'col' => 'image_file_id'
60
            ],
61
            'catalogs' => [
62
                'type' => 'many',
63
                'model' => 'Callbacks\Category',
64
                'col' => 'parent_id',
65
            ]
66
        ];
67
    }
68
69
    public function resolveTemplate() {
70
        if ($this->template !== 'inherit') {

system/modules/Migrations/models/Migration/Map/Path.php 1 location

@@ 26-46 (lines=21) @@
23
        'date_create' => ['type' => 'dateTime'],
24
    ];
25
26
    public static function relations() {
27
        return [
28
            'map' => [
29
                'model' => 'Migrations\Migration\Map',
30
                'col' => 'map_id'
31
            ],
32
            'object' => [
33
                'model' => 'Migrations\Migration\Object',
34
                'col' => 'object_id'
35
            ],
36
            'childs' => [
37
                'type' => 'many',
38
                'model' => 'Migrations\Migration\Map\Path',
39
                'col' => 'parent_id'
40
            ],
41
            'parent' => [
42
                'model' => 'Migrations\Migration\Map\Path',
43
                'col' => 'parent_id'
44
            ]
45
        ];
46
    }
47
48
}
49

system/modules/Materials/models/Material.php 1 location

@@ 114-134 (lines=21) @@
111
        ]
112
    ];
113
114
    public static function relations() {
115
        return [
116
            'category' => [
117
                'model' => '\Materials\Category',
118
                'col' => 'category_id'
119
            ],
120
            'image' => [
121
                'model' => '\Files\File',
122
                'col' => 'image_file_id'
123
            ],
124
            'user' => [
125
                'model' => '\Users\User',
126
                'col' => 'user_id'
127
            ],
128
            'links' => [
129
                'type' => 'many',
130
                'model' => '\Materials\Material\Link',
131
                'col' => 'material_id'
132
            ]
133
        ];
134
    }
135
136
    public function getHref() {
137
        $href = !empty(\App::$primary->config['defaultModule']) && \App::$primary->config['defaultModule'] == 'Materials' ? '' : '/materials';

system/modules/Ecommerce/models/Item/Option.php 1 location

@@ 96-116 (lines=21) @@
93
        ]
94
    ];
95
96
    public static function relations() {
97
        return [
98
            'user' => [
99
                'model' => 'Users\User',
100
                'col' => 'user_id'
101
            ],
102
            'group' => [
103
                'model' => 'Ecommerce\Item\Option\Group',
104
                'col' => 'item_option_group_id'
105
            ],
106
            'items' => [
107
                'type' => 'many',
108
                'model' => 'Ecommerce\Item\Option\Item',
109
                'col' => 'item_option_id'
110
            ],
111
            'image' => [
112
                'model' => 'Files\File',
113
                'col' => 'image_file_id'
114
            ],
115
        ];
116
    }
117
118
    public function beforeSave() {
119
        if (!isset($this->id) && class_exists('Users\User')) {

system/modules/Ecommerce/models/Catalog.php 1 location

@@ 75-96 (lines=22) @@
72
        }
73
    }
74
75
    static function relations() {
76
        return [
77
            'parent' => [
78
                'model' => 'Ecommerce\Catalog',
79
                'col' => 'parent_id'
80
            ],
81
            'childs' => [
82
                'type' => 'many',
83
                'col' => 'parent_id',
84
                'model' => 'Ecommerce\Catalog'
85
            ],
86
            'categories' => [
87
                'type' => 'many',
88
                'col' => 'catalog_id',
89
                'model' => 'Ecommerce\Catalog\Category'
90
            ],
91
            'icon' => [
92
                'col' => 'icon_file_id',
93
                'model' => 'Files\File'
94
            ]
95
        ];
96
    }
97
}