Conditions | 1 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace GeneaLabs\LaravelModelCaching; |
||
7 | protected function eagerLoadRelation(array $models, $name, Closure $constraints) |
||
|
|||
8 | { |
||
9 | $relation = $this->getRelation($name); |
||
10 | $relation->addEagerConstraints($models); |
||
11 | $constraints($relation); |
||
12 | |||
13 | $parentName = str_slug(get_class($relation->getParent())); |
||
14 | $childName = str_slug(get_class($relation->getModel())); |
||
15 | $results = cache()->tags([$parentName, $childName]) |
||
16 | ->rememberForever("{$parentName}-{$childName}-relation", function () use ($relation) { |
||
17 | return $relation->getEager(); |
||
18 | }); |
||
19 | |||
20 | return $relation->match( |
||
21 | $relation->initRelation($models, $name), |
||
22 | $results, |
||
23 | $name |
||
24 | ); |
||
27 |