/**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Platform::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'embed_url_pattern', $this->embed_url_pattern])->andFilterWhere(['like', 'download_url_pattern', $this->download_url_pattern]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Platform::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'platform', $this->platform])->andFilterWhere(['like', 'remark', $this->remark]);
     return $dataProvider;
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [['platform', 'in', 'range' => ArrayHelper::getColumn(Platform::find()->asArray()->all(), 'id')]];
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlatform()
 {
     return $this->hasOne(Platform::className(), ['id' => 'platform_id']);
 }
 /**
  * Finds the Platform model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Platform the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Platform::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
            <div class="">
                <?php 
$this->beginBlock('main');
?>
                <p>
        			<?php 
echo $form->field($model, 'user_id')->dropDownList(User::getMappedArray());
?>
        			<?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        			<?php 
echo $form->field($model, 'id_url')->textInput(['maxlength' => true]);
?>
        			<?php 
echo $form->field($model, 'platform_id')->dropDownList(Platform::getMappedArray());
?>
                    <?php 
if (!$model->isNewRecord) {
    ?>
                        <?php 
    echo $form->field($model, 'views')->textInput();
    ?>
                    <?php 
}
?>
                    <?php 
echo $form->field($model, 'is_active')->checkBox();
?>

                    <div class="form-group">
示例#7
0
 /**
  * @return string
  */
 public function actionAuth($id)
 {
     $app = $this->findModel($id);
     $model = new AuthPlatformForm();
     $data = Platform::find()->asArray()->all();
     $platforms = ArrayHelper::map($data, 'id', 'remark');
     $authPlatform = AuthPlatform::findAll(['app_id' => $id]);
     foreach ($authPlatform as $item) {
         $model->platform[$item->platform->id] = $item->platform->id;
     }
     if ($model->load(Yii::$app->request->post())) {
         $auth = Yii::$app->getAuthManager();
         foreach ($auth->getPermissions() as $item) {
             $arr = explode('_', $item->name);
             if (count($arr) == 3 && $arr[0] == 'platform' && $arr[1] == $app->app_code) {
                 $auth->remove($item);
             }
         }
         AuthPlatform::deleteAll(['app_id' => $id]);
         $model->platform = $model->platform == "" ? [] : $model->platform;
         foreach ($model->platform as $platform_id) {
             $authModel = new AuthPlatform();
             $authModel->app_id = $id;
             $authModel->platform_id = $platform_id;
             if ($authModel->save()) {
                 $platModel = Platform::findOne(['id' => $platform_id]);
                 $item = $auth->createPermission('platform_' . $app->app_code . '_' . $platModel->platform);
                 $item->description = $app->app_name . '-' . $platModel->remark;
                 $auth->add($item);
             }
         }
         Yii::$app->session->setFlash('success', '修改成功');
         $this->redirect(['index']);
     }
     return $this->render('auth', ['model' => $model, 'app' => $app, 'platforms' => $platforms]);
 }