public function getSearch(Request $req) { if (!$_GET) { return redirect()->action('SiteController@getIndex'); } $query = $req->input('q', ''); $paid = $req->input('paid', 0); $place = $req->input('place', ''); $all_types = EventType::toTransList(); $types = $req->input('types', []); $ilikey = function (string $str) { return strtr(" {$str} ", ' ', '%'); }; /** @var Builder $db_query */ $db_query = Event::where('hidden', 0); if ($query) { $db_query->where('title', 'ilike', $ilikey($query)); } //FIXME: improve this text search if ($paid) { $db_query->where('free', $paid == -1); } if ($place) { $db_query->where('location', 'ilike', $ilikey($place)); } if ($types) { $db_query->whereIn('event_type_id', $types); } $events = $db_query->get(); if (sizeof($events) == 1 && $query) { return redirect()->to(act('event@details', $events[0]->slug)); } return view('event.search', compact('query', 'paid', 'place', 'all_types', 'types', 'events')); }
public function getEvents(string $id_slug, Request $req) { $id = unslug($id_slug)[0]; $paid = $req->input('paid', 0); $theme = Theme::with('events')->find($id); $types = \App\Models\EventType::toTransList(); return view('theme.events', compact('theme', 'paid', 'types')); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::table('events', function ($t) { $t->text('slug')->after('title'); $t->unique('slug'); $t->dropColumn('location'); $t->integer('location_id')->change(); $t->dropTimestamps(); $t->renameColumn('hidden', 'published'); }); $talk = \App\Models\EventType::where('name', 'single talk')->first(); $talk->name = 'talk'; $talk->save(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EventType::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\widgets\ListView; ?> <div class="page-heading"> <div class="container"> <h2>Тренинги</h2> <div class="gap"></div> <div class="col-md-12"> <div class="row"> <?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get', 'id' => 'event-search-form']); ?> <div class="col-md-3"> <?php echo $form->field($searchModel, 'type')->dropDownList(ArrayHelper::map(EventType::find()->all(), 'id', 'name'), ['prompt' => 'Любой тип тренинга'])->label(false); ?> </div> <div class="col-md-3"> <?php echo $form->field($searchModel, 'city_id')->dropDownList(ArrayHelper::map(City::find()->where(['region_id' => '10373'])->orderBy('name')->all(), 'city_id', 'name'), ['prompt' => 'В любом городе'])->label(false); ?> </div> <div class="col-md-6"> <!--<button type="submit" class="btn-style">Искать</button>--> <?php echo Html::submitButton('Искать', ['class' => 'btn-style']); ?> </div> <?php ActiveForm::end();
/** * Finds the EventType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EventType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EventType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
} ?> <?php if ($showField('location')) { ?> <?php echo Form::labelInput('location', _('City'), 'text'); } ?> <?php if ($showField('event_type_id')) { ?> <?php echo Form::labelSelect('event_type_id', _('Event type'), EventType::toTransList(_('Select an option'))); } ?> <?php if ($showField('begin')) { ?> <?php echo Form::labelInput('begin', _('Begin'), 'date', $event->begin ? $event->begin->format('Y-m-d') : null); } ?> <?php if ($showField('end')) { ?> <?php
public function getIndex() { $types = array_flip(EventType::toList()); return view('site.index', compact('types')); }
<div class="col-md-12"> <?php echo $form->field($imagesModel, 'image_file')->fileInput()->label('Выберите фото'); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'type')->dropDownList(ArrayHelper::map(EventType::find()->all(), 'id', 'name'), ['prompt' => 'Укажите тип тренинга']); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'date')->textInput(['id' => 'eventDateInput']); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'duration')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-4"> <?php