当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::whereBetween方法代码示例

本文整理汇总了PHP中app\Event::whereBetween方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::whereBetween方法的具体用法?PHP Event::whereBetween怎么用?PHP Event::whereBetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Event的用法示例。


在下文中一共展示了Event::whereBetween方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $range = [];
     // Add "From" date to query
     $range[] = Carbon::parse($request->input('start'))->toDateTimeString();
     // Add "To" date to query
     $range[] = Carbon::parse($request->input('end'))->toDateTimeString();
     return Event::whereBetween('start_time', $range)->where('hidden', false)->get();
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:14,代码来源:EventsController.php

示例2: getUpcomingEvents

 /**
  * Gets upcoming events for specified days. Defaults to 3 days
  *
  * @return array
  */
 protected function getUpcomingEvents($days = 3)
 {
     $events = Event::whereBetween('start_time', [Carbon::now('America/Los_Angeles')->setTimezone('UTC'), Carbon::now('America/Los_Angeles')->addDays(2)->endOfDay()->setTimezone('UTC')])->get()->sortBy('start_time')->groupBy(function ($date) {
         return Carbon::parse($date->start_time, 'UTC')->setTimezone('America/Los_Angeles')->format('l');
         // grouping data by day
     });
     $result = [];
     // Get events for the next 3 days (including nulls)
     $date = Carbon::now('America/Los_Angeles');
     for ($i = 0; $i < $days; $i++) {
         $day = $date->format('l');
         // Set day or null if not found
         $result[$day] = isset($events[$day]) ? $events[$day] : null;
         $date->addDay();
     }
     return $result;
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:22,代码来源:HomeController.php

示例3: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($slug)
 {
     // TODO Add a comments feed for each event.
     $event = Event::findBySlug($slug);
     // Check if exists
     if (!$event) {
         abort(404);
     }
     $event->load('creator', 'chair', 'registrations', 'guests');
     // Look for events in the upcoming week
     $range = [Carbon::now(), Carbon::now()->addDays(6)];
     $upcoming_events = Event::whereBetween('start_time', $range)->get()->sortBy('start_time')->groupBy(function ($date) {
         return Carbon::parse($date->start_time)->timezone('UTC')->setTimezone('America/Los_Angeles')->format('l');
         // grouping data by day
     });
     return view('pages.event', compact('event', 'upcoming_events'));
 }
开发者ID:natalieduong,项目名称:konnection,代码行数:23,代码来源:EventsController.php


注:本文中的app\Event::whereBetween方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。