-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathQueryBuilderMixin.php
More file actions
54 lines (45 loc) · 1.36 KB
/
QueryBuilderMixin.php
File metadata and controls
54 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/** @noinspection DebugFunctionUsageInspection */
/** @noinspection ForgottenDebugOutputInspection */
/** @noinspection PhpMethodParametersCountMismatchInspection */
/** @noinspection PhpUnused */
declare(strict_types=1);
/**
* Copyright (c) 2020-2026 guanguans<ityaozm@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/guanguans/laravel-soar
*/
namespace Guanguans\LaravelSoar\Mixins;
use Guanguans\LaravelSoar\Facades\Soar;
/**
* @api
*
* @mixin \Illuminate\Database\Eloquent\Builder
* @mixin \Illuminate\Database\Eloquent\Relations\Relation
* @mixin \Illuminate\Database\Query\Builder
*/
class QueryBuilderMixin
{
public function ddSoarScore(): \Closure
{
return fn (int $depth = 512, int $options = 0): mixed => dd($this->toSoarScore($depth, $options)); // @codeCoverageIgnore
}
public function dumpSoarScore(): \Closure
{
return function (int $depth = 512, int $options = 0): self {
dump($this->toSoarScore($depth, $options));
return $this;
};
}
public function toSoarScore(): \Closure
{
return fn (int $depth = 512, int $options = 0): array => Soar::arrayScores(
$this->toRawSql(),
$depth,
$options
)[0];
}
}