/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Autocat::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', 'name_ru', $this->name_ru])->andFilterWhere(['like', 'name_en', $this->name_en])->andFilterWhere(['like', 'name_az', $this->name_az])->andFilterWhere(['like', 'maxpas', $this->maxpas])->andFilterWhere(['like', 'photo', $this->photo]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdcat0() { return $this->hasOne(Autocat::className(), ['id' => 'idcat']); }
public function actionAccardion() { $auto = Autocat::find()->joinWith('autos')->orderBy(['autocat.id' => SORT_ASC])->asArray()->all(); return $this->renderPartial('accardion', ['auto' => $auto]); }
/** * Finds the Autocat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Autocat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Autocat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use yii\widgets\ActiveForm; use common\models\Autocat; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model common\models\Auto */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="auto-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'idcat')->dropDownList(ArrayHelper::map(Autocat::find()->all(), 'id', 'name_az'), ['prompt' => ''])->label(false); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'photo')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'carnumber')->textInput(['maxlength' => true]); ?> <div class="form-group">