Completed
Push — master ( 22bc8c...4e6ac6 )
by Arjay
02:26
created

QueryBuilderEngine::compileColumnSearch()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 2 Features 1
Metric Value
c 3
b 2
f 1
dl 0
loc 12
rs 8.8571
cc 5
eloc 9
nc 6
nop 4
1
<?php
2
3
namespace Yajra\Datatables\Engines;
4
5
use Closure;
6
use Illuminate\Database\Query\Builder;
7
use Illuminate\Support\Str;
8
use Yajra\Datatables\Helper;
9
use Yajra\Datatables\Request;
10
11
/**
12
 * Class QueryBuilderEngine.
13
 *
14
 * @package Yajra\Datatables\Engines
15
 * @author  Arjay Angeles <[email protected]>
16
 */
17
class QueryBuilderEngine extends BaseEngine
18
{
19
    /**
20
     * @param \Illuminate\Database\Query\Builder $builder
21
     * @param \Yajra\Datatables\Request $request
22
     */
23
    public function __construct(Builder $builder, Request $request)
24
    {
25
        $this->query = $builder;
26
        $this->init($request, $builder);
27
    }
28
29
    /**
30
     * Initialize attributes.
31
     *
32
     * @param  \Yajra\Datatables\Request $request
33
     * @param  \Illuminate\Database\Query\Builder $builder
34
     * @param  string $type
35
     */
36
    protected function init($request, $builder, $type = 'builder')
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
37
    {
38
        $this->request    = $request;
39
        $this->query_type = $type;
40
        $this->columns    = $builder->columns;
41
        $this->connection = $builder->getConnection();
42
        $this->prefix     = $this->connection->getTablePrefix();
43
        $this->database   = $this->connection->getDriverName();
44
        if ($this->isDebugging()) {
45
            $this->connection->enableQueryLog();
46
        }
47
    }
48
49
    /**
50
     * Set auto filter off and run your own filter.
51
     * Overrides global search
52
     *
53
     * @param \Closure $callback
54
     * @return $this
55
     */
56
    public function filter(Closure $callback)
57
    {
58
        $this->overrideGlobalSearch($callback, $this->query);
59
60
        return $this;
61
    }
62
63
    /**
64
     * Organizes works
65
     *
66
     * @param bool $mDataSupport
67
     * @param bool $orderFirst
68
     * @return \Illuminate\Http\JsonResponse
69
     */
70
    public function make($mDataSupport = false, $orderFirst = false)
71
    {
72
        return parent::make($mDataSupport, $orderFirst);
73
    }
74
75
    /**
76
     * Count total items.
77
     *
78
     * @return integer
79
     */
80
    public function totalCount()
81
    {
82
        return $this->count();
83
    }
84
85
    /**
86
     * Counts current query.
87
     *
88
     * @return int
89
     */
90
    public function count()
91
    {
92
        $myQuery = clone $this->query;
93
        // if its a normal query ( no union, having and distinct word )
94
        // replace the select with static text to improve performance
95
        if (! Str::contains(Str::lower($myQuery->toSql()), ['union', 'having', 'distinct', 'order by', 'group by'])) {
0 ignored issues
show
Bug introduced by
The method toSql does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
96
            $row_count = $this->connection->getQueryGrammar()->wrap('row_count');
97
            $myQuery->select($this->connection->raw("'1' as {$row_count}"));
0 ignored issues
show
Bug introduced by
The method select does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
98
        }
99
100
        return $this->connection->table($this->connection->raw('(' . $myQuery->toSql() . ') count_row_table'))
101
                                ->setBindings($myQuery->getBindings())->count();
0 ignored issues
show
Bug introduced by
The method getBindings does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
102
    }
103
104
    /**
105
     * Perform global search.
106
     *
107
     * @return void
108
     */
109
    public function filtering()
110
    {
111
        $this->query->where(
112
            function ($query) {
113
                $globalKeyword = $this->setupKeyword($this->request->keyword());
114
                $queryBuilder  = $this->getQueryBuilder($query);
115
116
                foreach ($this->request->searchableColumnIndex() as $index) {
117
                    $columnName = $this->getColumnName($index);
118
                    if ($this->isBlacklisted($columnName)) {
119
                        continue;
120
                    }
121
122
                    // check if custom column filtering is applied
123
                    if (isset($this->columnDef['filter'][$columnName])) {
124
                        $columnDef = $this->columnDef['filter'][$columnName];
125
                        // check if global search should be applied for the specific column
126
                        $applyGlobalSearch = count($columnDef['parameters']) == 0 || end($columnDef['parameters']) !== false;
127
                        if (! $applyGlobalSearch) {
128
                            continue;
129
                        }
130
131
                        if ($columnDef['method'] instanceof Closure) {
132
                            $whereQuery = $queryBuilder->newQuery();
133
                            call_user_func_array($columnDef['method'], [$whereQuery, $this->request->keyword()]);
134
                            $queryBuilder->addNestedWhereQuery($whereQuery, 'or');
135
                        } else {
136
                            $this->compileColumnQuery(
137
                                $queryBuilder,
138
                                Helper::getOrMethod($columnDef['method']),
139
                                $columnDef['parameters'],
140
                                $columnName,
141
                                $this->request->keyword()
142
                            );
143
                        }
144
                    } else {
145
                        if (count(explode('.', $columnName)) > 1) {
146
                            $eagerLoads     = $this->getEagerLoads();
147
                            $parts          = explode('.', $columnName);
148
                            $relationColumn = array_pop($parts);
149
                            $relation       = implode('.', $parts);
150
                            if (in_array($relation, $eagerLoads)) {
151
                                $this->compileRelationSearch(
152
                                    $queryBuilder,
153
                                    $relation,
154
                                    $relationColumn,
155
                                    $globalKeyword
156
                                );
157
                            } else {
158
                                $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
159
                            }
160
                        } else {
161
                            $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
162
                        }
163
                    }
164
165
                    $this->isFilterApplied = true;
166
                }
167
            }
168
        );
169
    }
170
171
    /**
172
     * Perform filter column on selected field.
173
     *
174
     * @param mixed $query
175
     * @param string|Closure $method
176
     * @param mixed $parameters
177
     * @param string $column
178
     * @param string $keyword
179
     */
180
    protected function compileColumnQuery($query, $method, $parameters, $column, $keyword)
181
    {
182
        if (method_exists($query, $method)
183
            && count($parameters) <= with(new \ReflectionMethod($query, $method))->getNumberOfParameters()
184
        ) {
185
            if (Str::contains(Str::lower($method), 'raw')
0 ignored issues
show
Bug introduced by
It seems like $method defined by parameter $method on line 180 can also be of type object<Closure>; however, Illuminate\Support\Str::lower() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
186
                || Str::contains(Str::lower($method), 'exists')
0 ignored issues
show
Bug introduced by
It seems like $method defined by parameter $method on line 180 can also be of type object<Closure>; however, Illuminate\Support\Str::lower() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
187
            ) {
188
                call_user_func_array(
189
                    [$query, $method],
190
                    $this->parameterize($parameters, $keyword)
191
                );
192
            } else {
193
                call_user_func_array(
194
                    [$query, $method],
195
                    $this->parameterize($column, $parameters, $keyword)
196
                );
197
            }
198
        }
199
    }
200
201
    /**
202
     * Build Query Builder Parameters.
203
     *
204
     * @return array
205
     */
206
    protected function parameterize()
207
    {
208
        $args       = func_get_args();
209
        $keyword    = count($args) > 2 ? $args[2] : $args[1];
210
        $parameters = Helper::buildParameters($args);
211
        $parameters = Helper::replacePatternWithKeyword($parameters, $keyword, '$1');
212
213
        return $parameters;
214
    }
215
216
    /**
217
     * Get eager loads keys if eloquent.
218
     *
219
     * @return array
220
     */
221
    protected function getEagerLoads()
222
    {
223
        if ($this->query_type == 'eloquent') {
224
            return array_keys($this->query->getEagerLoads());
0 ignored issues
show
Bug introduced by
The method getEagerLoads does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Query\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
225
        }
226
227
        return [];
228
    }
229
230
    /**
231
     * Add relation query on global search.
232
     *
233
     * @param mixed $query
234
     * @param string $relation
235
     * @param string $column
236
     * @param string $keyword
237
     */
238
    protected function compileRelationSearch($query, $relation, $column, $keyword)
239
    {
240
        $myQuery = clone $this->query;
241
        $myQuery->orWhereHas($relation, function ($q) use ($column, $keyword, $query) {
0 ignored issues
show
Bug introduced by
The method orWhereHas does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Query\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
242
            $sql = $q->select($this->connection->raw('count(1)'))
243
                     ->where($column, 'like', $keyword)
244
                     ->toSql();
245
            $sql = "($sql) >= 1";
246
            $query->orWhereRaw($sql, [$keyword]);
247
        });
248
    }
249
250
    /**
251
     * Add a query on global search.
252
     *
253
     * @param mixed $query
254
     * @param string $column
255
     * @param string $keyword
256
     */
257
    protected function compileGlobalSearch($query, $column, $keyword)
258
    {
259
        if ($this->isSmartSearch()) {
260
            $column = $this->castColumn($column);
261
            $sql    = $column . ' LIKE ?';
262
            if ($this->isCaseInsensitive()) {
263
                $sql     = 'LOWER(' . $column . ') LIKE ?';
264
                $keyword = Str::lower($keyword);
265
            }
266
267
            $query->orWhereRaw($sql, [$keyword]);
268
        } else { // exact match
269
            $query->orWhereRaw("$column like ?", [$keyword]);
270
        }
271
    }
272
273
    /**
274
     * Wrap a column and cast in pgsql.
275
     *
276
     * @param  string $column
277
     * @return string
278
     */
279
    public function castColumn($column)
280
    {
281
        $column = $this->connection->getQueryGrammar()->wrap($column);
282
        if ($this->database === 'pgsql') {
283
            $column = 'CAST(' . $column . ' as TEXT)';
284
        }
285
286
        return $column;
287
    }
288
289
    /**
290
     * Perform column search.
291
     *
292
     * @return void
293
     */
294
    public function columnSearch()
295
    {
296
        $columns = $this->request->get('columns', []);
297
298
        foreach ($columns as $index => $column) {
299
            if (! $this->request->isColumnSearchable($index)) {
300
                continue;
301
            }
302
303
            $column = $this->getColumnName($index);
304
305
            if (isset($this->columnDef['filter'][$column])) {
306
                $columnDef = $this->columnDef['filter'][$column];
307
                // get a raw keyword (without wildcards)
308
                $keyword = $this->getSearchKeyword($index, true);
309
                $builder = $this->getQueryBuilder();
310
311
                if ($columnDef['method'] instanceof Closure) {
312
                    $whereQuery = $builder->newQuery();
313
                    call_user_func_array($columnDef['method'], [$whereQuery, $keyword]);
314
                    $builder->addNestedWhereQuery($whereQuery);
315
                } else {
316
                    $this->compileColumnQuery(
317
                        $builder,
318
                        $columnDef['method'],
319
                        $columnDef['parameters'],
320
                        $column,
321
                        $keyword
322
                    );
323
                }
324
            } else {
325
                $column          = $this->castColumn($column);
326
                $keyword         = $this->getSearchKeyword($index);
327
                $caseInsensitive = $this->isCaseInsensitive();
328
329
                if (! $caseInsensitive) {
330
                    $column = strstr($column, '(') ? $this->connection->raw($column) : $column;
331
                }
332
333
                $this->compileColumnSearch($index, $column, $keyword, $caseInsensitive);
334
            }
335
336
            $this->isFilterApplied = true;
337
        }
338
    }
339
340
    /**
341
     * Get proper keyword to use for search.
342
     *
343
     * @param int $i
344
     * @param bool $raw
345
     * @return string
346
     */
347
    private function getSearchKeyword($i, $raw = false)
348
    {
349
        $keyword = $this->request->columnKeyword($i);
350
        if ($raw || $this->request->isRegex($i)) {
351
            return $keyword;
352
        }
353
354
        return $this->setupKeyword($keyword);
355
    }
356
357
    /**
358
     * Compile queries for column search.
359
     *
360
     * @param int $i
361
     * @param mixed $column
362
     * @param string $keyword
363
     * @param bool $caseSensitive
364
     */
365
    protected function compileColumnSearch($i, $column, $keyword, $caseSensitive = true)
366
    {
367
        if ($this->request->isRegex($i)) {
368
            $this->regexColumnSearch($column, $keyword, $caseSensitive);
369
        } elseif ($this->isSmartSearch()) {
370
            $sql     = $caseSensitive ? $column . ' LIKE ?' : 'LOWER(' . $column . ') LIKE ?';
371
            $keyword = $caseSensitive ? $keyword : Str::lower($keyword);
372
            $this->query->whereRaw($sql, [$keyword]);
0 ignored issues
show
Bug introduced by
The method whereRaw does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
373
        } else { // exact match
374
            $this->query->whereRaw("$column LIKE ?", [$keyword]);
375
        }
376
    }
377
378
    /**
379
     * Compile regex query column search.
380
     *
381
     * @param mixed $column
382
     * @param string $keyword
383
     * @param bool $caseSensitive
384
     */
385
    protected function regexColumnSearch($column, $keyword, $caseSensitive = true)
386
    {
387
        if ($this->isOracleSql()) {
388
            $sql = $caseSensitive ? 'REGEXP_LIKE( ' . $column . ' , ? )' : 'REGEXP_LIKE( LOWER(' . $column . ') , ?, \'i\' )';
389
            $this->query->whereRaw($sql, [$keyword]);
0 ignored issues
show
Bug introduced by
The method whereRaw does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
390
        } else {
391
            $sql = $caseSensitive ? $column . ' REGEXP ?' : 'LOWER(' . $column . ') REGEXP ?';
392
            $this->query->whereRaw($sql, [Str::lower($keyword)]);
393
        }
394
    }
395
396
    /**
397
     * Perform sorting of columns.
398
     *
399
     * @return void
400
     */
401
    public function ordering()
402
    {
403
        if ($this->orderCallback) {
404
            call_user_func($this->orderCallback, $this->getQueryBuilder());
405
406
            return;
407
        }
408
409
        foreach ($this->request->orderableColumns() as $orderable) {
410
            $column = $this->getColumnName($orderable['column'], true);
411
412
            if ($this->isBlacklisted($column)) {
413
                continue;
414
            }
415
416
            if (isset($this->columnDef['order'][$column])) {
417
                $method     = $this->columnDef['order'][$column]['method'];
418
                $parameters = $this->columnDef['order'][$column]['parameters'];
419
                $this->compileColumnQuery(
420
                    $this->getQueryBuilder(),
421
                    $method,
422
                    $parameters,
423
                    $column,
424
                    $orderable['direction']
425
                );
426
            } else {
427
                if (count(explode('.', $column)) > 1) {
428
                    $eagerLoads     = $this->getEagerLoads();
429
                    $parts          = explode('.', $column);
430
                    $relationColumn = array_pop($parts);
431
                    $relation       = implode('.', $parts);
432
433
                    if (in_array($relation, $eagerLoads)) {
434
                        $column = $this->joinEagerLoadedColumn($relation, $relationColumn);
435
                    }
436
                }
437
438
                $this->getQueryBuilder()->orderBy($column, $orderable['direction']);
439
            }
440
        }
441
    }
442
443
    /**
444
     * Join eager loaded relation and get the related column name.
445
     *
446
     * @param string $relation
447
     * @param string $relationColumn
448
     * @return string
449
     */
450
    protected function joinEagerLoadedColumn($relation, $relationColumn)
451
    {
452
        $table   = $this->query->getRelation($relation)->getRelated()->getTable();
0 ignored issues
show
Bug introduced by
The method getRelation does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Query\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
453
        $foreign = $this->query->getRelation($relation)->getQualifiedForeignKey();
454
        $other   = $this->query->getRelation($relation)->getQualifiedOtherKeyName();
455
        $column  = $table . '.' . $relationColumn;
456
457
        $joins = [];
458
        foreach ((array) $this->getQueryBuilder()->joins as $key => $join) {
459
            $joins[] = $join->table;
460
        }
461
462
        if (! in_array($table, $joins)) {
463
            $this->getQueryBuilder()
464
                 ->leftJoin($table, $foreign, '=', $other);
465
        }
466
467
        return $column;
468
    }
469
470
    /**
471
     * Perform pagination
472
     *
473
     * @return void
474
     */
475
    public function paging()
476
    {
477
        $this->query->skip($this->request['start'])
0 ignored issues
show
Bug introduced by
The method skip does only exist in Illuminate\Database\Query\Builder, but not in Illuminate\Database\Eloquent\Builder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
478
                    ->take((int) $this->request['length'] > 0 ? $this->request['length'] : 10);
479
    }
480
481
    /**
482
     * Get results
483
     *
484
     * @return array|static[]
485
     */
486
    public function results()
487
    {
488
        return $this->query->get();
489
    }
490
}
491