@@ 215-228 (lines=14) @@ | ||
212 | * |
|
213 | * @return object|null The related resource if found else null |
|
214 | */ |
|
215 | public function getRelatedResourceReference( |
|
216 | ResourceSet $sourceResourceSet, |
|
217 | $sourceEntityInstance, |
|
218 | ResourceSet $targetResourceSet, |
|
219 | ResourceProperty $targetProperty |
|
220 | ) { |
|
221 | if (!($sourceEntityInstance instanceof Model)) { |
|
222 | throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
|
223 | } |
|
224 | $this->checkSourceInstance($sourceEntityInstance); |
|
225 | ||
226 | $propertyName = $targetProperty->getName(); |
|
227 | return $sourceEntityInstance->$propertyName; |
|
228 | } |
|
229 | ||
230 | /** |
|
231 | * Gets a related entity instance from an entity set identified by a key |
|
@@ 242-254 (lines=13) @@ | ||
239 | * |
|
240 | * @return object|null Returns entity instance if found else null |
|
241 | */ |
|
242 | public function getResourceFromRelatedResourceSet( |
|
243 | ResourceSet $sourceResourceSet, |
|
244 | $sourceEntityInstance, |
|
245 | ResourceSet $targetResourceSet, |
|
246 | ResourceProperty $targetProperty, |
|
247 | KeyDescriptor $keyDescriptor |
|
248 | ) { |
|
249 | if (!($sourceEntityInstance instanceof Model)) { |
|
250 | throw new InvalidArgumentException('Source entity must be an Eloquent model.'); |
|
251 | } |
|
252 | $propertyName = $targetProperty->getName(); |
|
253 | return $this->getResource(null, $keyDescriptor, [], $sourceEntityInstance->$propertyName); |
|
254 | } |
|
255 | ||
256 | ||
257 | /** |