Illuminate\Database\Eloquent\Model::getRelationValue PHP Метод

getRelationValue() публичный Метод

Get a relationship.
public getRelationValue ( string $key ) : mixed
$key string
Результат mixed
    public function getRelationValue($key)
    {
        // If the key already exists in the relationships array, it just means the
        // relationship has already been loaded, so we'll just return it out of
        // here because there is no need to query within the relations twice.
        if ($this->relationLoaded($key)) {
            return $this->relations[$key];
        }
        // If the "attribute" exists as a method on the model, we will just assume
        // it is a relationship and will load and return results from the query
        // and hydrate the relationship's value on the "relationships" array.
        if (method_exists($this, $key)) {
            return $this->getRelationshipFromMethod($key);
        }
    }

Usage Example

Пример #1
0
 /**
  * Get a relationship.
  *
  * @param  string $key
  * @return mixed
  */
 public function getRelationValue($key)
 {
     $return = parent::getRelationValue($key);
     if (is_null($return)) {
         $return = $this->getRelationshipFromMethod($key);
     }
     return $return;
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::getRelationValue
Model