|
@@ 294-309 (lines=16) @@
|
| 291 |
|
* |
| 292 |
|
* @return object|null The related resource if found else null |
| 293 |
|
*/ |
| 294 |
|
public function getRelatedResourceReference( |
| 295 |
|
ResourceSet $sourceResourceSet, |
| 296 |
|
$sourceEntityInstance, |
| 297 |
|
ResourceSet $targetResourceSet, |
| 298 |
|
ResourceProperty $targetProperty |
| 299 |
|
) { |
| 300 |
|
if (!($sourceEntityInstance instanceof Model)) { |
| 301 |
|
throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
| 302 |
|
} |
| 303 |
|
$this->checkSourceInstance($sourceEntityInstance); |
| 304 |
|
|
| 305 |
|
$this->checkAuth($sourceEntityInstance); |
| 306 |
|
|
| 307 |
|
$propertyName = $targetProperty->getName(); |
| 308 |
|
return $sourceEntityInstance->$propertyName; |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
/** |
| 312 |
|
* Gets a related entity instance from an entity set identified by a key |
|
@@ 323-335 (lines=13) @@
|
| 320 |
|
* |
| 321 |
|
* @return object|null Returns entity instance if found else null |
| 322 |
|
*/ |
| 323 |
|
public function getResourceFromRelatedResourceSet( |
| 324 |
|
ResourceSet $sourceResourceSet, |
| 325 |
|
$sourceEntityInstance, |
| 326 |
|
ResourceSet $targetResourceSet, |
| 327 |
|
ResourceProperty $targetProperty, |
| 328 |
|
KeyDescriptor $keyDescriptor |
| 329 |
|
) { |
| 330 |
|
if (!($sourceEntityInstance instanceof Model)) { |
| 331 |
|
throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
| 332 |
|
} |
| 333 |
|
$propertyName = $targetProperty->getName(); |
| 334 |
|
return $this->getResource(null, $keyDescriptor, [], $sourceEntityInstance->$propertyName); |
| 335 |
|
} |
| 336 |
|
|
| 337 |
|
|
| 338 |
|
/** |