Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

@@ 944-961 (lines=18) @@
941
            $query->join($join[0], $join[1]);
942
        }
943
        static::$relJoins = [];
944
        foreach (static::$needJoin as $rel) {
945
            $relations = static::relations();
946
            if (isset($relations[$rel])) {
947
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
948
                switch ($type) {
949
                    case 'to':
950
                        $relCol = $relations[$rel]['col'];
951
                        static::fixPrefix($relCol);
952
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
953
                        break;
954
                    case 'one':
955
                        $col = $relations[$rel]['col'];
956
                        $relations[$rel]['model']::fixPrefix($col);
957
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
958
                        break;
959
                }
960
            }
961
        }
962
        static::$needJoin = [];
963
964
        if (!empty($options['limit'])) {
@@ 1276-1293 (lines=18) @@
1273
            $query->join($join[0], $join[1]);
1274
        }
1275
        static::$relJoins = [];
1276
        foreach (static::$needJoin as $rel) {
1277
            $relations = static::relations();
1278
            if (isset($relations[$rel])) {
1279
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
1280
                switch ($type) {
1281
                    case 'to':
1282
                        $relCol = $relations[$rel]['col'];
1283
                        static::fixPrefix($relCol);
1284
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
1285
                        break;
1286
                    case 'one':
1287
                        $col = $relations[$rel]['col'];
1288
                        $relations[$rel]['model']::fixPrefix($col);
1289
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
1290
                        break;
1291
                }
1292
            }
1293
        }
1294
        static::$needJoin = [];
1295
        $cols = 'COUNT(';
1296