예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Site::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]);
     $query->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'taxId', $this->taxId])->andFilterWhere(['like', 'site_type', $this->site_type]);
     return $dataProvider;
 }
예제 #2
0
파일: Cm.php 프로젝트: jackieit/aimocms
 public function getSite()
 {
     return $this->hasOne(Site::className(), ['id' => 'site_id']);
 }
예제 #3
0
 /**
  * Finds the Site model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Site the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $model = Site::find()->where(['id' => $id])->with('materials')->one();
     if ($model !== null) {
         return $model;
     } else {
         Yii::$app->response->format = 'json';
         Yii::$app->response->setStatusCode(404);
         return ['message' => 'Record not found'];
         die;
     }
 }
예제 #4
0
 /**
  * Updates an existing Node model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $model->scenario = 'update';
     $parent = Node::findOne($model->parent);
     $site = Site::findOne($model->site_id);
     if (isset($parent)) {
         $model->parent_txt = $parent->name;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'site' => $site]);
     }
 }
예제 #5
0
 /**
  * Finds the Site model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Site the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Site::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 public function actionGetSites($q)
 {
     $query = Site::find()->select(['s.id', 's.name'])->from(['s' => Site::tableName()]);
     if (empty($q)) {
         $query->andWhere(['or', ['like', 's.name', $q]]);
     }
     $list = $query->all();
     $result = [];
     foreach ($list as $site) {
         $domain_arr = ArrayHelper::getColumn($site->domains, 'domain');
         $result[] = ['value' => $site->name . "|" . implode('|', $domain_arr), 'data' => $site->id];
     }
     $response = Yii::$app->response;
     $response->format = $response::FORMAT_JSON;
     return $result;
 }