Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

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