|
@@ 306-321 (lines=16) @@
|
| 303 |
|
* |
| 304 |
|
* @return object|null The related resource if found else null |
| 305 |
|
*/ |
| 306 |
|
public function getRelatedResourceReference( |
| 307 |
|
ResourceSet $sourceResourceSet, |
| 308 |
|
$sourceEntityInstance, |
| 309 |
|
ResourceSet $targetResourceSet, |
| 310 |
|
ResourceProperty $targetProperty |
| 311 |
|
) { |
| 312 |
|
if (!($sourceEntityInstance instanceof Model)) { |
| 313 |
|
throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
| 314 |
|
} |
| 315 |
|
$this->checkSourceInstance($sourceEntityInstance); |
| 316 |
|
|
| 317 |
|
$this->checkAuth($sourceEntityInstance); |
| 318 |
|
|
| 319 |
|
$propertyName = $targetProperty->getName(); |
| 320 |
|
return $sourceEntityInstance->$propertyName; |
| 321 |
|
} |
| 322 |
|
|
| 323 |
|
/** |
| 324 |
|
* Gets a related entity instance from an entity set identified by a key |
|
@@ 335-347 (lines=13) @@
|
| 332 |
|
* |
| 333 |
|
* @return object|null Returns entity instance if found else null |
| 334 |
|
*/ |
| 335 |
|
public function getResourceFromRelatedResourceSet( |
| 336 |
|
ResourceSet $sourceResourceSet, |
| 337 |
|
$sourceEntityInstance, |
| 338 |
|
ResourceSet $targetResourceSet, |
| 339 |
|
ResourceProperty $targetProperty, |
| 340 |
|
KeyDescriptor $keyDescriptor |
| 341 |
|
) { |
| 342 |
|
if (!($sourceEntityInstance instanceof Model)) { |
| 343 |
|
throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
| 344 |
|
} |
| 345 |
|
$propertyName = $targetProperty->getName(); |
| 346 |
|
return $this->getResource(null, $keyDescriptor, [], $sourceEntityInstance->$propertyName); |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
|
| 350 |
|
/** |