Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

@@ 934-951 (lines=18) @@
931
            $query->join($join[0], $join[1]);
932
        }
933
        static::$relJoins = [];
934
        foreach (static::$needJoin as $rel) {
935
            $relations = static::relations();
936
            if (isset($relations[$rel])) {
937
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
938
                switch ($type) {
939
                    case 'to':
940
                        $relCol = $relations[$rel]['col'];
941
                        static::fixPrefix($relCol);
942
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
943
                        break;
944
                    case 'one':
945
                        $col = $relations[$rel]['col'];
946
                        $relations[$rel]['model']::fixPrefix($col);
947
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
948
                        break;
949
                }
950
            }
951
        }
952
        static::$needJoin = [];
953
954
        if (!empty($options['limit'])) {
@@ 1263-1280 (lines=18) @@
1260
            $query->join($join[0], $join[1]);
1261
        }
1262
        static::$relJoins = [];
1263
        foreach (static::$needJoin as $rel) {
1264
            $relations = static::relations();
1265
            if (isset($relations[$rel])) {
1266
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
1267
                switch ($type) {
1268
                    case 'to':
1269
                        $relCol = $relations[$rel]['col'];
1270
                        static::fixPrefix($relCol);
1271
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
1272
                        break;
1273
                    case 'one':
1274
                        $col = $relations[$rel]['col'];
1275
                        $relations[$rel]['model']::fixPrefix($col);
1276
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
1277
                        break;
1278
                }
1279
            }
1280
        }
1281
        static::$needJoin = [];
1282
        $cols = 'COUNT(';
1283