/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Movie::find(); $query->andFilterWhere(['state' => AppActiveRecord::STATUS_DELETE]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['Id' => $this->Id, 'launguageId' => $this->launguageId, 'starRating' => $this->starRating, 'oldStarRating' => $this->oldStarRating, 'avgerageUserRate' => $this->avgerageUserRate, 'reviewCount' => $this->reviewCount, 'releaseDate' => $this->releaseDate, 'createdOn' => $this->createdOn, 'status' => $this->status, 'length' => $this->length, 'toiMovieId' => $this->toiMovieId, 'topLevelCount' => $this->topLevelCount, 'recommendedCount' => $this->recommendedCount, 'agreeCount' => $this->agreeCount, 'disagreeCount' => $this->disagreeCount, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'entityType' => $this->entityType, 'state' => $this->state]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'cast', $this->cast])->andFilterWhere(['like', 'synopsis', $this->synopsis])->andFilterWhere(['like', 'parentalGuidance', $this->parentalGuidance])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'tagline', $this->tagline])->andFilterWhere(['like', 'review', $this->review])->andFilterWhere(['like', 'movieDirector', $this->movieDirector])->andFilterWhere(['like', 'musicDirector', $this->musicDirector])->andFilterWhere(['like', 'oldGuid', $this->oldGuid])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'shortCode', $this->shortCode])->andFilterWhere(['like', 'canonicalUrl', $this->canonicalUrl])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Movie::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', $this->name]); return $dataProvider; }
<?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'hall_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Hall::find()->all(), 'id', 'hall_name'), ['prompt' => 'Select Hall']); ?> <?php echo $form->field($model, 'start_time')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Time::find()->where(['6' => '0'])->all(), 'time_id', 'time_list'), ['prompt' => 'Select time', "disabled" => "disabled"]); ?> <?php echo $form->field($model, 'movie_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Movie::find()->all(), 'id', 'name'), ['prompt' => 'Select Movie', "disabled" => "disabled"]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div> <script>
public function actionMovieautosuggest($search = null) { Yii::$app->response->format = Response::FORMAT_JSON; $query = \common\models\Movie::find(); if ($search) { $query->andFilterWhere(['like', 'name', $search . '%', false]); } //*/ $query->andFilterWhere(['status' => \common\component\AppActiveRecord::STATUS_PUBLISH]); //*/ $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $data = []; foreach ($dataProvider->getModels() as $model) { $NameString = $model->name . ' (' . $model->languagename . ')'; //$NameString = (string)$model->Id; $data[] = ['id' => $model->Id, 'text' => $NameString]; } return $data; }