/** * Magic setter * * @param string $key * @param mixed $value */ public function __set($key, $value) { if ($key == 'data') { $value = is_null($value) ? null : json_encode($value); } parent::__set($key, $value); }
/** * Handles setting of all model values, and tracks changes between values. * * @param string column name * @param mixed column value * @return void */ public function __set($column, $value) { switch ($column) { // Set access type case 'area_type': $types = self::area_types(); if (!isset($types[$value])) { throw new Kohana_Exception('The area type :type does not exist in the :class class', array(':type' => $value, ':class' => get_class($this))); } $old_access = $this->__get('access'); parent::__set('access', $old_access | $value); break; default: parent::__set($column, $value); } }
/** * Magic setter * * @param string $key * @param mixed $value */ public function __set($key, $value) { switch ($key) { // Date of birth case 'dob': $value = date::format(date::DATE_SQL, $value); break; // Always lowercase e-mail // Always lowercase e-mail case 'email': $value = utf8::strtolower($value); break; // Use Auth to hash the password // Use Auth to hash the password case 'password': $value = Visitor::instance()->hash_password($value); break; } parent::__set($key, $value); }