/**
  * Finds the City model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return City the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = City::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::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(['code' => $this->code]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Exemple #3
0
 public function getCity()
 {
     return $this->hasOne(City::className(), ['id' => 'cityId']);
 }
Exemple #4
0
            <?php 
if ($model->type == \app\modules\discount\models\Request::TYPE_CLIENT) {
    ?>
                <h2>Регистрация клиента</h2>
            <?php 
}
?>
            <br/>
            <?php 
$form = ActiveForm::begin();
?>
            <?php 
echo $form->field($model, 'username')->textInput(['placeholder' => 'Имя']);
?>
            <?php 
echo $form->field($model, 'cityId')->dropDownList(\app\modules\cms\models\City::dropDown(), ['placeholder' => 'Город']);
?>
            <?php 
echo $form->field($model, 'phone')->textInput(['placeholder' => 'Номер телефона']);
?>
            <?php 
echo $form->field($model, 'email')->textInput(['placeholder' => 'Эмаил']);
?>
            <button type="submit"></button>
            <?php 
ActiveForm::end();
?>
        </div>
        <div class="slider">
            <div class="slider_container">
                <div class="flexslider">
            <div class="panel-footer">
                <p>
                    Эти данные будут использоваться в дальнейшем для авторизации в личном кабинете.
                </p>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="panel panel-green">
            <div class="panel-heading">
                Персональные данные:
            </div>
            <div class="panel-body">

                <?php 
echo $form->field($profile, 'cityId')->dropDownList(\app\modules\cms\models\City::dropDown());
?>

                <?php 
echo $form->field($profile, 'name')->textInput();
?>

                <?php 
echo $form->field($profile, 'phone')->textInput();
?>

                <?php 
echo $form->field($profile, 'file')->fileInput();
?>

            </div>
Exemple #6
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\discount\models\RequestSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Заявки');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="request-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'username', ['attribute' => 'cityId', 'value' => 'city.title', 'filter' => \app\modules\cms\models\City::dropDown()], 'email:email', 'phone', ['attribute' => 'status', 'value' => 'statusText', 'filter' => \app\modules\discount\models\Request::getStatusList()], 'dateCreate:date', 'dateActivate:date', ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['accept' => function ($url, $model) {
    return Html::a('<i class="fa fa-users"></i>', $url, ['class' => 'btn btn-success btn-xs']);
}, 'update' => function ($url, $model) {
    return Html::a('<i class="fa fa-edit"></i>', $url, ['class' => 'btn btn-primary btn-xs']);
}, 'reject' => function ($url, $model) {
    return Html::a('<i class="fa fa-undo"></i>', $url, ['class' => 'btn btn-danger btn-xs']);
}], 'template' => '{accept} | {reject} | {view} |{delete}', 'options' => ['class' => 'col-md-1', 'style' => 'width:130px;text-align:center']]]]);
?>

</div>