/** @inheritdoc */
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         //            $this->RoomID = $session->RoomID;
     }
     return parent::beforeValidate();
 }
Exemplo n.º 2
0
 public function fields()
 {
     $fields = parent::fields();
     $fields['Color'] = function () {
         return dechex($this->Color);
     };
     return $fields;
 }
Exemplo n.º 3
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if ($this->_data !== null) {
             $this->Settings = $this->_data->toString();
         }
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public function fields()
 {
     $fields = parent::fields();
     unset($fields['Deleted']);
     return $fields;
 }
Exemplo n.º 5
0
 /**
  * @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;
 }
Exemplo n.º 6
0
 /**
  * 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);
 }