public function actionSelect($app_id, $app_secret) { $session = Yii::$app->session; $model = App::findOne(['app_id' => $app_id, 'app_secret' => $app_secret]); if (!Yii::$app->user->can('app_' . $model->app_code)) { throw new ForbiddenHttpException('没有该项目权限'); } $session['api_url'] = $model->api_url; $session['app_code'] = $model->app_code; $session['app_name'] = $model->app_name; $this->redirect(['main/add']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = App::find(); $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; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'cp_id' => $this->cp_id, 'active' => $this->active]); $query->andFilterWhere(['like', 'app_name', $this->app_name])->andFilterWhere(['like', 'app_id', $this->app_id])->andFilterWhere(['like', 'app_secret', $this->app_secret])->andFilterWhere(['like', 'app_code', $this->app_code])->andFilterWhere(['like', 'version', $this->version]); $query->andWhere(['in', 'app_code', Tools::getPrevApp()]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getApp() { return $this->hasOne(App::className(), ['id' => 'app_id']); }
/** * @return \yii\db\ActiveQuery */ public function getApps() { return $this->hasMany(App::className(), ['cp_id' => 'id']); }
/** * @inheritdoc */ public function controlAttributes() { return [['id' => 'basic', 'name' => '基本属性', 'attributes' => ['name' => ['type' => 'text'], 'parent_id' => ['type' => 'tree', 'pkAttrName' => 'menu_id', 'showAttrName' => 'name', 'items' => function () { return static::find()->asArray()->all(); }, 'topItem' => [0 => '顶级菜单']], 'app' => ['type' => 'dropDown', 'items' => [App::className(), 'getAppsItems']], 'module' => ['type' => 'text'], 'controller' => ['type' => 'text'], 'action' => ['type' => 'text'], 'params' => ['type' => 'text', 'hint' => '额外附加到生成地址的参数,比如a=1&b=2'], 'sort' => ['type' => 'text'], 'type' => ['type' => 'dropDown', 'items' => [static::className(), 'getTypeItems']], 'auth_rules' => ['type' => 'checkbox', 'items' => [Auth::className(), 'getRuleItems']], 'remark' => ['type' => 'textarea'], 'status' => ['type' => 'radio', 'items' => [static::className(), 'getStatusItems']]]]]; }
/** * Finds the App model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return App the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = App::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }