|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| - declare(strict_types=1); |
| 3 | +declare(strict_types=1); |
4 | 4 |
|
5 |
| - namespace PDPhilip\Elasticsearch\Relations\Traits; |
| 5 | +namespace PDPhilip\Elasticsearch\Relations\Traits; |
6 | 6 |
|
7 |
| - use BackedEnum; |
8 |
| - |
9 |
| - trait InteractsWithPivotTable |
10 |
| - { |
| 7 | +use BackedEnum; |
11 | 8 |
|
| 9 | +trait InteractsWithPivotTable |
| 10 | +{ |
12 | 11 | /** {@inheritdoc} */
|
13 | 12 | protected function formatRecordsList(array $records)
|
14 | 13 | {
|
15 |
| - return collect($records)->mapWithKeys(function ($attributes, $id) { |
16 |
| - if (! is_array($attributes)) { |
17 |
| - [$id, $attributes] = [$attributes, []]; |
18 |
| - } |
19 |
| - |
20 |
| - if ($id instanceof BackedEnum) { |
21 |
| - $id = $id->value; |
22 |
| - } |
23 |
| - |
24 |
| - // We have to convert all Key Ids to string values to keep it consistent in Elastic. |
25 |
| - return [(string) $id => $attributes]; |
26 |
| - })->all(); |
| 14 | + return collect($records)->mapWithKeys(function ($attributes, $id) { |
| 15 | + if (! is_array($attributes)) { |
| 16 | + [$id, $attributes] = [$attributes, []]; |
| 17 | + } |
| 18 | + |
| 19 | + if ($id instanceof BackedEnum) { |
| 20 | + $id = $id->value; |
| 21 | + } |
| 22 | + |
| 23 | + // We have to convert all Key Ids to string values to keep it consistent in Elastic. |
| 24 | + return [(string) $id => $attributes]; |
| 25 | + })->all(); |
27 | 26 | }
|
28 | 27 |
|
29 | 28 | /** {@inheritdoc} */
|
30 | 29 | protected function parseIds($value)
|
31 | 30 | {
|
32 |
| - // We have to convert all Key Ids to string values to keep it consistent in Elastic. |
33 |
| - return collect(parent::parseIds($value))->mapWithKeys(function ($value, $key) { |
34 |
| - return [(string) $key => $value]; |
35 |
| - })->all(); |
| 31 | + // We have to convert all Key Ids to string values to keep it consistent in Elastic. |
| 32 | + return collect(parent::parseIds($value))->mapWithKeys(function ($value, $key) { |
| 33 | + return [(string) $key => $value]; |
| 34 | + })->all(); |
36 | 35 | }
|
37 |
| - |
38 |
| - } |
| 36 | +} |
0 commit comments