コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Parameters::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, 'digit' => $this->digit, 'status' => $this->status, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'units', $this->units])->andFilterWhere(['like', 'is_range', $this->is_range])->andFilterWhere(['like', 'icon', $this->icon]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Products.php プロジェクト: cubiclab/store-cube
 public function getAllParameters()
 {
     if ($this->_parameters) {
         return $this->_parameters;
     }
     if ($this->id) {
         $id = $this->id;
     } else {
         $id = 0;
     }
     $this->_parameters = ParametersValues::find()->select('*')->rightJoin(Parameters::tableName() . ' as a', ParametersValues::tableName() . '.`param_id` = `a`.`id` AND ' . ParametersValues::tableName() . '.product_id = ' . (int) $id)->where(['a.status' => Parameters::STATUS_ACTIVE])->groupBy(['id'])->orderBy('order')->all();
     return $this->_parameters;
 }
コード例 #3
0
 /**
  * Finds the Parameters model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Parameters the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Parameters::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getParam()
 {
     return $this->hasOne(Parameters::className(), ['id' => 'param_id']);
 }