/** @inheritdoc */ public function beforeValidate() { if ($this->isNewRecord) { // $this->RoomID = $session->RoomID; } return parent::beforeValidate(); }
public function fields() { $fields = parent::fields(); $fields['Color'] = function () { return dechex($this->Color); }; return $fields; }
public function beforeValidate() { if (parent::beforeValidate()) { if ($this->_data !== null) { $this->Settings = $this->_data->toString(); } return true; } else { return false; } }
public function fields() { $fields = parent::fields(); unset($fields['Deleted']); return $fields; }
/** * @inheritdoc * @return static|null ActiveRecord instance matching the condition, or `null` if nothing matches. */ public static function findOne($condition) { $model = parent::findOne($condition); if (null !== $model) { $settings = $model->parseSettings(); $model->class = $settings['class']; } return $model; }
/** * Applying actions!!! * @todo attach as event handler * @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert) { Yii::info(Html::a('Пользователь №' . $this->ContractorID, ['/user/admin/update', 'id' => $this->ContractorID]) . ' Транзакция: ID ' . $this->id . ': ' . $this->action->Name . ', сумма ' . $this->CashSum, 'info'); if ($this->CashSum > 0) { //Применение акций! $discounts = ActionsRecord::getDiscounts(); foreach ($discounts as $discount) { $discount->apply($this); } } } }
/** @inheritdoc */ public function beforeSave($insert) { $this->Items = Json::encode($this->_items); if ($insert) { $this->AccountantID = Yii::$app->user->id; } return parent::beforeSave($insert); }