示例#1
0
 public function __set($propertyName, $value)
 {
     if (!$this->defaultsSet) {
         $this->setDefaultValues();
     }
     if ($propertyName == $this->uniqueIdentifierColumnName) {
         $this->uniqueIdentifier = $value;
     }
     if (isset(self::$modelDataTransforms[$this->modelName][$propertyName][1])) {
         $closure = self::$modelDataTransforms[$this->modelName][$propertyName][1];
         $value = $closure($value);
     }
     if (strpos($propertyName, ".") !== false) {
         $parts = explode(".", $propertyName);
         $firstStep = $this[$parts[0]];
         if ($firstStep === null || !$firstStep instanceof Model) {
             // If the next item in the chain is not model object we can't ask it to
             // set it's value.
             return;
         }
         $firstStep[$parts[1]] = $value;
     } else {
         parent::__set($propertyName, $value);
         if (isset($this->propertyCache[$propertyName])) {
             $this->propertyCache[$propertyName] = $propertyName;
         }
     }
 }