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


PHP Appointment::timeBetween方法代码示例

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


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

示例1: getTimes

 /**
  * Function to retrieve times available for a given date
  *
  * View is returned in JSON format
  *
  **/
 public function getTimes()
 {
     // We get the data from AJAX for the day selected, then we get all available times for that day
     $selectedDay = Input::get('selectedDay');
     $availableTimes = DB::select('SELECT id, booking_datetime AS bdate, strftime("%H:%M", booking_datetime) AS bdatetime FROM booking_datetimes WHERE strftime("%Y-%m-%d", booking_datetime)="' . $selectedDay . '"');
     // PSEUDO CODE
     // Get package duration of the chosen package
     $package = Package::find(Session::get('packageID'));
     $packageTime = $package->package_time;
     // For each available time...
     foreach ($availableTimes as $t => $value) {
         //get the start and end times of that time
         $startTime = new DateTime($value->bdate);
         $endTime = new DateTime($value->bdate);
         date_add($endTime, date_interval_create_from_date_string($packageTime . ' hours'));
         // Try to grab any appointments between the start time and end time
         $result = Appointment::timeBetween($startTime->format("Y-m-d H:i"), $endTime->format("Y-m-d H:i"));
         // If no records are returned, the time is okay, if not, we must remove it from the array
         if ($result->first()) {
             unset($availableTimes[$t]);
         }
     }
     return Response::make(View::make('getTimes')->with('selectedDay', $selectedDay)->with('availableTimes', $availableTimes), 200, array('Content-Type' => 'application/json'));
 }
开发者ID:RetinaInc,项目名称:booking-app,代码行数:30,代码来源:BookingController.php


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