| 1 | <?php |
||
| 8 | class RelationshipIterator |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The primary record. |
||
| 12 | */ |
||
| 13 | private $record; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * The path to the relation. |
||
| 17 | * |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | private $path; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Create a new RelationshipIterator instance. |
||
| 24 | * |
||
| 25 | * @param Model $record The primary record |
||
| 26 | * @param string $path The path to the relation |
||
| 27 | */ |
||
| 28 | public function __construct($record, $path) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Validate if the given relation path can be resolved. |
||
| 40 | * |
||
| 41 | * @return bool |
||
| 42 | */ |
||
| 43 | public function validate() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Resolve the relationship from the primary record. |
||
| 56 | * |
||
| 57 | * @throws InvalidRelationPathException |
||
| 58 | * |
||
| 59 | * @return Collection|Model|null |
||
| 60 | */ |
||
| 61 | public function resolve() |
||
| 71 | } |
||
| 72 |