/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Clubs::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', 'addres', $this->addres])->andFilterWhere(['like', 'cityID', $this->cityID])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
public static function getClubsList() { // Выбираем только те категории, у которых есть дочерние категории $parents = Clubs::find()->select(['id', 'name'])->all(); return ArrayHelper::map($parents, 'id', 'name'); }
?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'password_hash')->textInput(['maxlength' => true]); ?> <?php //$form->field($model, 'date')->textInput() ?> <?php $clubs = \app\models\Clubs::find()->all(); $items = ArrayHelper::map($clubs, 'id', 'name'); $params = ['prompt' => 'Выберите клуб']; echo $form->field($model, 'clubID')->dropDownList($items, $params); ?> <?php echo $form->field($model, 'fullName')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Изменить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getClub() { return $this->hasOne(Clubs::className(), ['id' => 'clubID']); }
public function getClubsVariants() { return $this->hasMany(Clubs::className(), ['clubID' => 'id']); //xz }
use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel app\models\SearchClubs */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Клубы'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="clubs-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' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', ['attribute' => 'cityID', 'label' => 'Город', 'format' => 'text', 'content' => function ($data) { return $data->getCityName(); }, 'filter' => \app\models\Clubs::getCityList()], 'addres', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
public function actionClubs() { if (Yii::$app->request->isAjax) { $cityID = Yii::$app->request->get('city'); if ($clubs = Clubs::find()->where(['cityID' => $cityID])->asArray()->all()) { return json_encode($clubs, JSON_UNESCAPED_UNICODE); } else { return 'No clubs in this city.'; } } return $this->redirect('index'); }
/** * @return \yii\db\ActiveQuery */ public function getClubs() { return $this->hasMany(Clubs::className(), ['cityID' => 'id']); }
/** * Finds the Clubs model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Clubs the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Clubs::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
?> <div class="row row-offcanvas row-offcanvas-right"> <div class="col-xs-12 col-sm-9"> <p class="pull-right visible-xs"> <button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">Меню</button> </p> <div class="row"> </div><!--/row--> </div><!--/span--> <?php $cities = \app\models\City::find()->count(); $clubs = \app\models\Clubs::find()->count(); $cards = \app\models\Cards::find()->count(); $types = \app\models\Types::find()->count(); $orders = \app\models\Order::find()->count(); $viziting = \app\models\Viziting::find()->count(); $duration = \app\models\Duration::find()->count(); ?> <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation"> <div class="list-group"> <?php if (Yii::$app->user->identity->username == "admin") { echo '<a href="/city" class="list-group-item">Города (' . $cities . ')</a> <a href="/clubs" class="list-group-item">Клубы (' . $clubs . ')</a> <a href="/cards" class="list-group-item">Карты (' . $cards . ')</a> <a href="/types" class="list-group-item">Типы карт (' . $types . ')</a>