public function actionIndex() { $directions = Directions::find()->all(); $transferForm = new TransferForm(); $cards = LoyaltyCard::find()->all(); return $this->render('index', ['cards' => $cards, 'directions' => $directions, 'transfer' => $transferForm]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Directions::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, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Directions::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'id_type_country' => $this->id_type_country, 'id_type_car' => $this->id_type_car, 'max_passengers' => $this->max_passengers]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'country', $this->country]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii\widgets\ActiveForm; use app\models\Directions; /* @var $this yii\web\View */ /* @var $model app\models\PlaceDestination */ /* @var $form yii\widgets\ActiveForm */ $itemsDirection = ArrayHelper::map(Directions::find()->all(), 'id', 'name'); ?> <div class="place-destination-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'id_direction')->dropDownList($itemsDirection); ?> <?php echo $form->field($model, 'attribute')->dropDownList($model->getArrayAttributes()); ?> <div class="form-group">
/* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Пункты назначения'; $this->params['breadcrumbs'][] = ['label' => 'Форма заказа трансфера', 'url' => ['/managecontent/order-form']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="place-destination-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Добавить пункт назначения', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id_direction' => ['label' => 'Направление', 'attribute' => 'id_direction', 'content' => function ($model, $key, $index, $column) { return \app\models\Directions::find()->where(['id' => $model->id_direction])->one()->name; }], 'name' => ['label' => 'Пункт назначения', 'attribute' => 'name'], 'attribute' => ['label' => 'Атрибут', 'attribute' => 'attribute', 'content' => function ($model, $key, $index, $column) { return $model->getAttributeName(); }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
public static function getAllDirections() { return Directions::find()->all(); }