@@ 326-341 (lines=16) @@ | ||
323 | * |
|
324 | * @return object|null The related resource if found else null |
|
325 | */ |
|
326 | public function getRelatedResourceReference( |
|
327 | ResourceSet $sourceResourceSet, |
|
328 | $sourceEntityInstance, |
|
329 | ResourceSet $targetResourceSet, |
|
330 | ResourceProperty $targetProperty |
|
331 | ) { |
|
332 | if (!($sourceEntityInstance instanceof Model)) { |
|
333 | throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
|
334 | } |
|
335 | $this->checkSourceInstance($sourceEntityInstance); |
|
336 | ||
337 | $this->checkAuth($sourceEntityInstance); |
|
338 | ||
339 | $propertyName = $targetProperty->getName(); |
|
340 | return $sourceEntityInstance->$propertyName; |
|
341 | } |
|
342 | ||
343 | /** |
|
344 | * Gets a related entity instance from an entity set identified by a key |
|
@@ 355-367 (lines=13) @@ | ||
352 | * |
|
353 | * @return object|null Returns entity instance if found else null |
|
354 | */ |
|
355 | public function getResourceFromRelatedResourceSet( |
|
356 | ResourceSet $sourceResourceSet, |
|
357 | $sourceEntityInstance, |
|
358 | ResourceSet $targetResourceSet, |
|
359 | ResourceProperty $targetProperty, |
|
360 | KeyDescriptor $keyDescriptor |
|
361 | ) { |
|
362 | if (!($sourceEntityInstance instanceof Model)) { |
|
363 | throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
|
364 | } |
|
365 | $propertyName = $targetProperty->getName(); |
|
366 | return $this->getResource(null, $keyDescriptor, [], $sourceEntityInstance->$propertyName); |
|
367 | } |
|
368 | ||
369 | ||
370 | /** |