コード例 #1
0
ファイル: Region.php プロジェクト: kitbs/vinfo
 public function getAttribute($key)
 {
     if ($key == 'name' && $this->region_type_id == 1) {
         return $this->country->name;
     }
     if (str_contains($key, ':')) {
         list($key, $locale) = explode(':', $key);
     } else {
         $locale = $this->locale();
     }
     if ($this->isTranslationAttribute($key)) {
         if ($this->getTranslation($locale) === null) {
             return;
         }
         return $this->getTranslation($locale)->{$key};
     }
     return parent::getAttribute($key);
 }
コード例 #2
0
ファイル: SetBuilder.php プロジェクト: matheusgomes17/baum
 /**
  * Return an array of the scoped attributes of the supplied node.
  *
  * @param   Baum\Node $node
  * @return  array
  */
 protected function scopedAttributes($node)
 {
     $keys = $this->node->getScopedColumns();
     if (count($keys) == 0) {
         return array();
     }
     $values = array_map(function ($column) use($node) {
         return $node->getAttribute($column);
     }, $keys);
     return array_combine($keys, $values);
 }