示例#1
0
 public function init()
 {
     parent::init();
     $this->customer_id = Yii::$app->user->id;
     $this->money = $this->status = $this->integral = $this->reference_no = 0;
     $this->level = 1;
     $this->attachEvents();
 }
示例#2
0
 public function __call($name, $arguments)
 {
     if (strlen($name) > 3 && substr($name, 0, 3) == 'get') {
         $key = lcfirst(substr($name, 3));
         return $this->getDataList($key);
     }
     return parent::__get($name);
 }
示例#3
0
 public function beforeSave($insert)
 {
     if (Yii::$app->user->isGuest) {
         return false;
     }
     $this->user_id = Yii::$app->user->id;
     return parent::beforeSave($insert);
 }
示例#4
0
 public function tryToSetRelation($name, $value)
 {
     if ($name == 'categoryIds') {
         return $this->setCategoryIds($value);
     }
     if ($name == 'tagIds') {
         return $this->setTagIds($value);
     }
     return parent::tryToSetRelation($name, $value);
 }
示例#5
0
 public function init()
 {
     parent::init();
     $this->attachEvents();
 }
示例#6
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['create'] = $this->attributes();
     return $scenarios;
 }
示例#7
0
文件: Cms.php 项目: yinheark/yincart2
 public function beforeSave($insert)
 {
     $this->updated_at = time();
     return parent::beforeSave($insert);
 }
示例#8
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     $instance = new static();
     $query = parent::find()->select("{$instance::tableName()}.*");
     foreach ($instance->_relations as $key => $relation) {
         $joinType = isset($relation['joinType']) ? $relation['joinType'] : 'leftJoin';
         if (isset($relation['table'])) {
             $relationTable = $instance->{$relation['table']}->tableName();
         } else {
             $relationTable = $instance::tableName();
         }
         $table = $instance->{$key}->tableName();
         if (is_array($relation['on'])) {
             $on = [];
             foreach ($relation['on'] as $k => $fk) {
                 $on[] = "{$table}.{$k} = {$relationTable}.{$fk}";
             }
             $on = implode(' AND ', $on);
         } else {
             $on = $relation['on'];
         }
         $params = isset($relation['params']) ? $relation['params'] : [];
         $query->{$joinType}($table, $on, $params)->addSelect("{$table}.*");
     }
     return $query;
 }
示例#9
0
 public function init()
 {
     parent::init();
     $this->initModel();
 }
示例#10
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     /** @var RelationModel $instance */
     $instance = new static();
     $query = parent::find();
     return $query;
 }
示例#11
0
 public static function find()
 {
     return parent::find()->where(['role' => static::ROLE_USER]);
 }
示例#12
0
 /**
  * @inheritdoc
  */
 public function setAttributes($values, $safeOnly = false)
 {
     parent::setAttributes($values, $safeOnly);
 }
示例#13
0
 public function init()
 {
     parent::init();
     $this->key = Yii::$app->security->generateRandomString();
 }