public function beforeSave() { if ($this->isNewRecord) { $this->user_id = Yii::app()->user->id; } return parent::beforeSave(); }
public static function model($className = __CLASS__) { return parent::model($className); }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return CustomerPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new CustomerPeer(); } return self::$peer; }
public function rules() { return array_merge(parent::rules()); }
public function __get($strName) { switch ($strName) { case 'state': return State::CodeById($this->state_id); case 'country': return Country::CodeById($this->country_id); case 'mainname': case 'full_name': return $this->first_name . " " . $this->last_name; case 'block': return $this->address1 . chr(13) . $this->address2 . chr(13) . $this->city . chr(13) . $this->state . chr(13) . " " . $this->postal . chr(13) . $this->country; case 'shipblock': return $this->first_name . " " . $this->last_name . (!empty($this->company) ? chr(13) . $this->company : "") . $this->company . chr(13) . $this->address1 . chr(13) . $this->address2 . chr(13) . $this->city . chr(13) . $this->state . chr(13) . " " . $this->postal . chr(13) . $this->country; default: return parent::__get($strName); } }
/** * takes care of sluggifying fields before saving */ public function preSave($event) { if (!$this->name_slug) { $this->name_slug = CustomerTable::slugify($this->name); } parent::preSave($event); }