Exemple #1
0
 /**
  * Updates an existing Basic model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $parent = Basic::find()->where(['id' => $model->pid])->one();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'parent' => $parent]);
     }
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Basic::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, 'pid' => $this->pid, 'orderid' => $this->orderid, 'create_uid' => $this->create_uid, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Exemple #3
0
 /**
  * Lists all Basic models.
  * @return mixed
  */
 public function actionIndex()
 {
     $params = Yii::$app->request->get();
     $query = Basic::find();
     #$query->where(['status' => Basic::STATUS_NORMAL]);
     if (isset($params['title'])) {
         $query->andWhere(['like', 'title', $params['title']]);
     }
     if (isset($params['original_title'])) {
         $query->andWhere(['like', 'original_title', $params['original_title']]);
     }
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $data = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('index', ['data' => $data, 'pages' => $pages, 'params' => $params]);
 }