Conditions | 4 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 1 | public function matchSimple(array &$models, Collection $results, $relation) |
|
22 | { |
||
23 | 1 | $dictionary = []; |
|
24 | |||
25 | 1 | foreach ($results as $result) { |
|
26 | 1 | $dictionary[ModelAccessor::get($result, 'laravel_through_key')][] = $result; |
|
27 | } |
||
28 | |||
29 | 1 | foreach ($models as &$model) { |
|
30 | 1 | $keyName = $this->parent->getKeyName(); |
|
31 | |||
32 | 1 | if (isset($dictionary[$key = ModelAccessor::get($model, $keyName)])) { |
|
33 | 1 | $value = $dictionary[$key]; |
|
34 | |||
35 | 1 | ModelAccessor::set($model, $relation, reset($value)); |
|
36 | } |
||
37 | } |
||
38 | 1 | unset($model); |
|
39 | |||
40 | 1 | return $models; |
|
41 | } |
||
56 |