Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

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