1 | <?php |
||
10 | class RelationshipIterator |
||
11 | { |
||
12 | /** |
||
13 | * The primary record. |
||
14 | */ |
||
15 | private $record; |
||
16 | |||
17 | /** |
||
18 | * The path to the relation. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | private $path; |
||
23 | |||
24 | /** |
||
25 | * Create a new RelationshipIterator instance. |
||
26 | * |
||
27 | * @param Model $record The primary record |
||
28 | * @param string $path The path to the relation |
||
29 | * |
||
30 | * @throws InvalidArgumentException |
||
31 | */ |
||
32 | public function __construct($record, string $path) |
||
41 | |||
42 | /** |
||
43 | * Resolve the relationship from the primary record. |
||
44 | * |
||
45 | * @return Collection|Model|null |
||
46 | */ |
||
47 | public function resolve() |
||
51 | |||
52 | /** |
||
53 | * Recursively iterate through a given relation path to return the resolved |
||
54 | * relationship value. |
||
55 | * |
||
56 | * @param Collection|Model|null $resolved |
||
57 | * @param string|null $path |
||
58 | * |
||
59 | * @return Collection|Model|null |
||
60 | */ |
||
61 | private function iterate($resolved, $path) |
||
83 | } |
||
84 |