예제 #1
0
 public function safeDown()
 {
     $this->dropTable('IF EXISTS ' . Websites::tableName());
     $this->dropTable('IF EXISTS ' . Tasks::tableName());
     $this->dropTable('IF EXISTS ' . Deploy::tableName());
     $this->dropTable('IF EXISTS ' . DeployHasTasks::tableName());
     $this->dropTable('IF EXISTS ' . WebsiteHasUser::tableName());
     return true;
 }
예제 #2
0
 public function actionUpdate($id)
 {
     /* @var Websites $model */
     $model = Websites::findOne($id);
     $form = new WebsiteForm();
     if ($form->load($_POST) && $form->validate()) {
         $model->setAttributes($form->getAttributes(null, ['user_id']), false);
         $model->on(Websites::EVENT_AFTER_UPDATE, function ($event) use($form) {
             $model = $event->sender;
             WebsiteHasUser::deleteAll(['website_id' => $model->id]);
             if ($form->user_id) {
                 WebsiteHasUser::batchInsertByCondition(['user_id'], explode(',', $form->user_id), ['website_id' => $model->id]);
             }
         });
         $model->update(false);
         return $this->redirect('index');
     }
     $form->setAttributes($model->getAttributes());
     $form->user_id = implode(',', ArrayHelper::getColumn($model->websiteHasUser, 'user_id'));
     return $this->render('update', ['model' => $form]);
 }
예제 #3
0
 public function getWebsite()
 {
     return $this->hasOne(Websites::className(), ['id' => 'websites_id']);
 }
예제 #4
0
 public function rules()
 {
     return [[['title', 'websites_id'], 'required', 'on' => 'apply'], ['websites_id', 'exist', 'targetClass' => Websites::className(), 'targetAttribute' => 'id', 'on' => 'apply'], ['status', 'default', 'value' => Tasks::STATUS_APPLY, 'on' => 'apply'], ['apply_time', 'default', 'value' => time(), 'on' => 'apply'], ['applicant', 'default', 'value' => (int) \Yii::$app->user->id, 'on' => 'apply'], ['hash', 'default', 'value' => $this->generatorVersion(), 'on' => 'apply']];
 }
예제 #5
0
 public function rules()
 {
     return [[['websites_id', 'tasks_id'], 'required'], ['websites_id', 'exist', 'targetClass' => Websites::className(), 'targetAttribute' => 'id'], ['tasks_id', 'exist', 'targetClass' => Tasks::className(), 'targetAttribute' => 'id', 'allowArray' => true, 'filter' => function ($query) {
         return $query->isPass();
     }], ['deployer', 'default', 'value' => (int) \Yii::$app->user->id], ['deploy_time', 'default', 'value' => time()], ['status', 'default', 'value' => Deploy::DEPLOY_SUCCESS]];
 }