Esempio n. 1
0
 public function search($params)
 {
     $query = Province::find();
     // join with relation `author` that is a relation to the table `users`
     // and set the table alias to be `author`
     $query->joinWith(['user' => function ($query) {
         $query->from(['u' => 'user']);
     }, 'country' => function ($query) {
         $query->from(['c' => 'country']);
     }]);
     $query->from(['p' => $this->tableName()]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['user.username'] = ['asc' => ['u.username' => SORT_ASC], 'desc' => ['u.username' => SORT_DESC]];
     $dataProvider->sort->attributes['country.name'] = ['asc' => ['c.name' => SORT_ASC], 'desc' => ['c.name' => SORT_DESC]];
     // load the seach form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // adjust the query by adding the filters
     $query->andFilterWhere(['p.id' => $this->id]);
     $query->andFilterWhere(['like', 'p.name', $this->name]);
     $query->andFilterWhere(['LIKE', 'u.username', $this->getAttribute('user.username')]);
     $query->andFilterWhere(['LIKE', 'c.name', $this->getAttribute('country.name')]);
     return $dataProvider;
 }
Esempio n. 2
0
 public function run()
 {
     $out = [];
     $parents = Yii::$app->getRequest()->post('depdrop_parents', null);
     if ($parents != null) {
         $country_id = $parents[0];
         $out = Province::find()->select(['id', 'name'])->where(['country_id' => $country_id])->asArray()->all();
         return Json::encode(['output' => $out, 'selected' => '']);
     }
     return Json::encode(['output' => '', 'selected' => '']);
 }
Esempio n. 3
0
$met_description = Yii::t('app', 'Introduce your business, Your business on the map, image gallery for your business, attachments for your business, Mark your business location in map');
$this->registerMetaTag(['property' => 'og:description', 'content' => $met_description]);
$this->registerMetaTag(['name' => 'description', 'content' => $met_description]);
$this->registerMetaTag(['name' => 'keywords', 'content' => $met_description]);
?>
<div class="row">
    <div class="col-md-2">
        <?php 
$form = ActiveForm::begin(['id' => $searchModel->formName(), 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'method' => 'get']);
?>
        <?php 
echo $form->field($searchModel, 'category_id')->widget(Select2::classname(), ['language' => Yii::$app->helper->getTwoCharLanguage(), 'size' => Select2::MEDIUM, 'options' => [], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 2, 'ajax' => ['url' => $categoriesListUrl, 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {search:params.term}; }'), 'results' => new JsExpression('function(data,page) { return {results:data.results}; }')], 'initSelection' => new JsExpression($initCategoriesListScript)]]);
?>
        <?php 
echo $form->field($searchModel, 'country_id')->widget(Select2::className(), ['data' => ArrayHelper::map(Country::find()->asArray()->all(), 'id', 'name'), 'language' => Yii::$app->helper->getTwoCharLanguage(), 'options' => ['placeholder' => Yii::t('app', 'Select...')], 'pluginOptions' => ['allowClear' => true]]);
echo $form->field($searchModel, 'province_id')->widget(DepDrop::classname(), ['data' => !$searchModel->country_id ? [] : ArrayHelper::map(Province::find()->where(['country_id' => $searchModel->country_id])->asArray()->all(), 'id', 'name'), 'type' => DepDrop::TYPE_SELECT2, 'options' => ['placeholder' => Yii::t('app', 'Select...')], 'select2Options' => ['pluginOptions' => ['allowClear' => true], 'language' => Yii::$app->helper->getTwoCharLanguage()], 'pluginOptions' => ['depends' => ['search-country_id'], 'url' => Url::to(['/province/dep-list']), 'loadingText' => Yii::t('app', 'Loading...')]]);
echo $form->field($searchModel, 'city_id')->widget(DepDrop::classname(), ['data' => !$searchModel->province_id ? [] : ArrayHelper::map(City::find()->where(['province_id' => $searchModel->province_id])->asArray()->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Select...')], 'type' => DepDrop::TYPE_SELECT2, 'select2Options' => ['pluginOptions' => ['allowClear' => true], 'language' => Yii::$app->helper->getTwoCharLanguage()], 'pluginOptions' => ['depends' => ['search-province_id'], 'url' => Url::to(['/city/dep-list']), 'loadingText' => Yii::t('app', 'Loading...')]]);
?>
            <?php 
echo $form->field($searchModel, 'title')->textInput();
?>
            <?php 
echo $form->field($searchModel, 'address')->textInput();
?>
            <?php 
echo Html::hiddenInput('view', $adverView, ['id' => 'hiddenViewMode']);
?>
        <div class="form-group">
            <?php 
echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']);
?>