示例#1
0
 /**
  * Get an attribute from the model.
  * Overrided from {@link Eloquent} to implement recognition of the {@link $relationsData} array.
  *
  * @param  string $key
  * @return mixed
  */
 public function getAttribute($key)
 {
     $attr = parent::getAttribute($key);
     if ($attr === null) {
         $camelKey = camel_case($key);
         if (array_key_exists($camelKey, static::$relationsData)) {
             $this->relations[$key] = $this->{$camelKey}()->getResults();
             return $this->relations[$key];
         }
     }
     return $attr;
 }