本文整理汇总了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'));
}