Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Models\Relations; |
| 4 | |
| 5 | use LdapRecord\Query\Collection; |
| 6 | |
| 7 | class HasManyIn extends OneToMany |
| 8 | { |
| 9 | /** |
| 10 | * Get the relationships results. |
| 11 | * |
| 12 | * @return Collection |
| 13 | */ |
| 14 | public function getRelationResults() |
| 15 | { |
| 16 | $results = $this->parent->newCollection(); |
| 17 | |
| 18 | foreach ((array) $this->parent->getAttribute($this->relationKey) as $value) { |
| 19 | if ($foreign = $this->getForeignModelByValue($value)) { |
| 20 | $results->push($foreign); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return $this->transformResults($results); |
| 25 | } |
| 26 | } |