getRelation() public method

Get a specified relationship.
public getRelation ( string $relation ) : mixed
$relation string
return mixed
Example #1
0
 /**
  * Get a specified relationship.
  *
  * @param  string $relation
  *
  * @return mixed
  */
 public function getRelation($relation)
 {
     return $this->dynamicRelation($relation) ?: parent::getRelation($relation);
 }
Example #2
0
 /**
  * Get property simple value by name.
  *
  * @param string $key
  *
  * @return mixed|Collection
  */
 public function getValue($key)
 {
     $value = $this->getPropertyValue($key);
     $property = $this->getProperties()->get($key);
     if ($value instanceof Collection) {
         /* @var MultipleCollection $collection
          * @var Collection $value
          */
         $collection = $this->entity->relationLoaded($key) ? $this->entity->getRelation($key) : null;
         if ($collection === null) {
             $collection = new MultipleCollection($this, $property);
         }
         $collection->setValues($value->map(function (Value $value) {
             return $value->getAttributeValue('value');
         }));
         return $collection;
     } elseif ($value instanceof Value) {
         return $value->getAttributeValue('value');
     }
 }