| Conditions | 2 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 9 | protected function getKeys(array $models, $key = null) |
|
| 20 | { |
||
| 21 | // The original function orders the results associatively by value which means the keys reorder too. |
||
| 22 | // However, a list of keys with unordered numeric keys will be recognized as an object down the line |
||
| 23 | // for json casting while we need a list of keys. |
||
| 24 | |||
| 25 | 9 | $keys = collect($models)->map(function ($value) use ($key) { |
|
|
|
|||
| 26 | 9 | return $key ? $value->getAttribute($key) : $value->getKey(); |
|
| 27 | 9 | })->values()->unique(null, true)->all(); |
|
| 28 | |||
| 29 | 9 | sort($keys); |
|
| 30 | |||
| 31 | 9 | return $keys; |
|
| 32 | } |
||
| 48 |