1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Zing\QueryBuilder\Concerns; |
||
6 | |||
7 | use Illuminate\Support\Collection; |
||
8 | use Illuminate\Support\Str; |
||
9 | |||
10 | trait NestedRelation |
||
11 | { |
||
12 | /** |
||
13 | * @return array{string, string} |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
14 | */ |
||
15 | 5 | protected function resolveNestedRelation(string $property): array |
|
16 | { |
||
17 | 5 | return collect(explode('.', $property)) |
|
18 | 5 | ->pipe( |
|
19 | 5 | function (Collection $parts): array { |
|
20 | return [ |
||
21 | 5 | $parts->except([\count($parts) - 1]) |
|
22 | 5 | ->map(function (string $value): string { |
|
23 | 5 | return Str::camel($value); |
|
24 | 5 | })->implode('.'), |
|
25 | 5 | $parts->last(), |
|
26 | ]; |
||
27 | } |
||
28 | ); |
||
29 | } |
||
30 | } |
||
31 |