/** * Search events. * * @param Request $request * @return \Illuminate\View\View */ public function events(Request $request) { $ip = $request->ip(); $ip = '73.85.49.134'; $geolocation = $this->ipGeolocator->ipToGeolocation($ip); $perPage = 4; $defaultDistance = 25; $input = $request->only(['keyword', 'distance', 'lat', 'lng', 'city', 'type']); $input['distance'] = $input['distance'] ?: $defaultDistance; if (!$input['city'] && $geolocation) { $input['lat'] = $geolocation['lat']; $input['lng'] = $geolocation['lng']; $input['city'] = $geolocation['city']; } $events = Event::query()->filterActive()->filterUpcoming()->orderBySoonest(); if ($input['keyword']) { $events->filterKeyword($input['keyword']); } if ($input['distance'] && is_numeric($input['distance'])) { $events->filterNearby($input['lat'], $input['lng'], $input['distance']); } if ($input['type']) { $events->filterTypes($input['type']); } $events = $events->paginate($perPage); $events->appends($input); return view('search.events.result', compact('events', 'input')); }
/** * Выводит события * * @return string * @throws \cs\web\Exception */ public function actionEvents() { return $this->render(['items' => Event::query()->limit(12)->where(['>=', 'end_date', gmdate('Ymd')])->orderBy(['start_date' => SORT_ASC])->all()]); }
public function actionIndex() { return $this->render('index', ['events' => \app\models\Event::query()->limit(3)->where(['>=', 'end_date', gmdate('Ymd')])->orderBy(['date_insert' => SORT_DESC])->all()]); }
public function actionIndex() { return $this->render(['items' => Event::query()->orderBy(['date_insert' => SORT_DESC])->all()]); }