Beispiel #1
0
 /**
  * PHP Magic Function: Set
  *
  * Override the method to extend the functionality (hash a password that is set as an attribute before adding it
  * to the model).
  *
  * @access public
  * @param string $name
  * @param mixed $value
  * @return void
  */
 public function __set($property, $value)
 {
     // If an override method exists for a certain property, call it to alter the value before passing it to the
     // model to be saved to the database.
     $method = 'set' . ucwords($property);
     if (method_exists($this, $method)) {
         $value = $this->{$method}($value);
     }
     // Carry on setting it to the model as normal.
     parent::__set($property, $value);
 }