Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| BelongsToManyThroughClosures | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| match | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Baril\Bonsai\Relations; |
| 4 | |
| 5 | use Baril\Bonsai\Relations\Concerns\ExcludesSelf; |
| 6 | use Baril\Bonsai\Relations\Concerns\InteractsWithClosureTable; |
| 7 | use Illuminate\Database\Eloquent\Collection as EloquentCollection; |
| 8 | use Illuminate\Database\Eloquent\Relations\BelongsToMany; |
| 9 | |
| 10 | /** |
| 11 | * @template TRelatedModel of \Illuminate\Database\Eloquent\Model |
| 12 | * @template TDeclaringModel of \Illuminate\Database\Eloquent\Model |
| 13 | * @template TPivotModel of \Baril\Bonsai\Closure = \Baril\Bonsai\Closure |
| 14 | * @template TAccessor of string = 'closure' |
| 15 | * |
| 16 | * @extends \Illuminate\Database\Eloquent\Relations\BelongsToMany<TRelatedModel, TDeclaringModel, TPivotModel, TAccessor> |
| 17 | */ |
| 18 | class BelongsToManyThroughClosures extends BelongsToMany |
| 19 | { |
| 20 | use ExcludesSelf { |
| 21 | ExcludesSelf::match as _match; |
| 22 | } |
| 23 | use InteractsWithClosureTable; |
| 24 | |
| 25 | /** |
| 26 | * Match the eagerly loaded results to their parents. |
| 27 | * |
| 28 | * @param array<int, TDeclaringModel> $models |
| 29 | * @param \Illuminate\Database\Eloquent\Collection<int, TRelatedModel> $results |
| 30 | * @param string $relation |
| 31 | * @return array<int, TDeclaringModel> |
| 32 | */ |
| 33 | public function match(array $models, EloquentCollection $results, $relation) |
| 34 | { |
| 35 | $this->_match($models, $results, $relation); |
| 36 | |
| 37 | $this->matchOtherRelations($models, $results); |
| 38 | $this->matchOtherRelations($results->all(), $results); |
| 39 | |
| 40 | return $models; |
| 41 | } |
| 42 | } |