コード例 #1
0
 public function search($params)
 {
     $query = Regions::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['country' => SORT_DESC, 'region_name' => SORT_ASC]], 'pagination' => ['pageSize' => 100]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'region_name', $this->region_name])->andFilterWhere(['like', 'country', $this->country]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: RegionsSearch.php プロジェクト: ut8ia/radioDoc
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Regions::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])->andFilterWhere(['like', 'name_en', $this->name_en]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Regions::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['country' => SORT_ASC, 'region_name' => SORT_ASC]]]);
     $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', 'region_name', $this->region_name])->andFilterWhere(['like', 'country', $this->country]);
     return $dataProvider;
 }
コード例 #4
0
 /**
  * Finds the Regions model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Regions the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Regions::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: Appellations.php プロジェクト: aekkapun/mysommelier
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegion()
 {
     return $this->hasOne(Regions::className(), ['id' => 'region_id']);
 }
コード例 #6
0
ファイル: index.php プロジェクト: nncrypted/mysommelier
 * @var app\models\AppellationsSearch $searchModel
 */
$this->title = 'Appellations';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="appellations-index">
    <div class="page-header">
            <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
/* echo Html::a('Create Appellations', ['create'], ['class' => 'btn btn-success'])*/
?>
    </p>

    <?php 
Pjax::begin();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'country', 'value' => 'country', 'hAlign' => GridView::ALIGN_CENTER, 'width' => '90px', 'filterType' => GridView::FILTER_SELECT2, 'filter' => Yii::$app->params['wine_countries'], 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true, 'width' => '150px']], 'filterInputOptions' => ['placeholder' => 'All Countries']], ['attribute' => 'region_id', 'header' => 'Region', 'value' => 'region.region_name', 'width' => '200px', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Regions::find()->orderBy('region_name')->asArray()->all(), 'id', 'region_name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true, 'width' => '200px']], 'filterInputOptions' => ['placeholder' => 'Any region']], 'app_name', 'common_flg', ['class' => 'kartik\\grid\\ActionColumn', 'width' => '70px', 'buttons' => ['update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', Yii::$app->urlManager->createUrl(['appellations/view', 'id' => $model->id, 'edit' => 't']), ['title' => Yii::t('yii', 'Edit')]);
}]]], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . ' </h3>', 'type' => 'info', 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> Add', ['create'], ['class' => 'btn btn-success']), 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset List', ['index'], ['class' => 'btn btn-info']), 'showFooter' => false]]);
Pjax::end();
?>
</div>