/**
  * Get an attribute.
  *
  * @param  string $key
  * @return mixed
  */
 public function getAttribute($key)
 {
     if ($key === 'locale') {
         return parent::getAttribute('locale');
     }
     if (!($parent = $this->getParent())) {
         return $this->attributes[$key];
     }
     /* @var AssignmentInterface $assignment */
     $assignment = $parent->getAssignment($key);
     if (!$assignment) {
         return parent::getAttribute($key);
     }
     $type = $assignment->getFieldType($this);
     $type->setEntry($this);
     $type->setLocale($this->locale);
     $accessor = $type->getAccessor();
     $modifier = $type->getModifier();
     return $modifier->restore($accessor->get($key));
 }
예제 #2
0
 /**
  * Get a raw unmodified attribute.
  *
  * @param      $key
  * @param bool $process
  * @return mixed|null
  */
 public function getRawAttribute($key, $process = true)
 {
     if (!$process) {
         return $this->getAttributeFromArray($key);
     }
     return parent::getAttribute($key);
 }
 /**
  * Parse a translation.
  *
  * @param EloquentModel $translation
  * @param               $string
  */
 protected function parseTranslation(EloquentModel $translation, &$string)
 {
     $string .= "\n[";
     foreach ($translation->getAttributes() as $key => $value) {
         $value = $translation->getAttribute($key);
         if (is_string($value)) {
             $value = addslashes($value);
         }
         $string .= "\n'{$key}' => '{$value}',";
     }
     $string .= "\n],";
 }