Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

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