Code Duplication    Length = 13-14 lines in 2 locations

src/Modules/Core/BaseClasses/BaseRepository.php 2 locations

@@ 90-102 (lines=13) @@
87
         */
88
        $model->where(function ($q) use ($query, $conditionColumns, $relations) {
89
90
            if (count($conditionColumns)) {
91
                $column = 'LOWER('.array_shift($conditionColumns).')';
92
                if (Str::contains($column, '->')) {
93
                    $column = $this->wrapJsonSelector($column);
94
                }
95
96
                /**
97
                 * Use the first element in the model columns to construct the first condition.
98
                 */
99
                $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
100
            }
101
102
            /**
103
             * Loop through the rest of the columns to construct or where conditions.
104
             */
105
            foreach ($conditionColumns as $column) {
@@ 139-152 (lines=14) @@
136
                             */
137
                            $subConditionColumns = \Core::$relation()->model->searchable;
138
139
                            if (count($subConditionColumns)) {
140
                                $column = 'LOWER('.array_shift($subConditionColumns).')';
141
                                if (Str::contains($column, '->')) {
142
                                    $column = $this->wrapJsonSelector($column);
143
                                }
144
145
                                /**
146
                                 * Use the first element in the relation model columns to construct the first condition.
147
                                 */
148
                                $q->where(\DB::raw($column), 'LIKE', '%'.strtolower($query).'%');
149
                            }
150
151
                            /**
152
                             * Loop through the rest of the columns to construct or where conditions.
153
                             */
154
                            foreach ($subConditionColumns as $subConditionColumn) {
155
                                $column = 'LOWER('.$subConditionColumn.')';