本文整理汇总了PHP中app\models\Event::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::query方法的具体用法?PHP Event::query怎么用?PHP Event::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: events
/**
* 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'));
}
示例2: actionEvents
/**
* Выводит события
*
* @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()]);
}
示例3: actionIndex
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()]);
}
示例4: actionIndex
public function actionIndex()
{
return $this->render(['items' => Event::query()->orderBy(['date_insert' => SORT_DESC])->all()]);
}