32 lines
1.2 KiB
PHP
32 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Models\Outlet;
|
|
|
|
if (!function_exists('checkOperationDateAndTime')) {
|
|
function checkOperationDateAndTime($outlet_id, $selected_date, $selected_time)
|
|
{
|
|
$outlet = new Outlet();
|
|
$outlet_operating_hours = $outlet->getOperatingHoursWithDays($outlet_id);
|
|
$operation_days = $outlet_operating_hours['operating_schedule']; //operation schedule and hours
|
|
|
|
$operation_date = $selected_date;
|
|
$operation_time = $selected_time.':00';
|
|
|
|
$day_of_week = date('l', strtotime($operation_date));
|
|
if(isset($operation_days[$day_of_week])){
|
|
if(!$operation_days[$day_of_week]['is_operated']){
|
|
return false;
|
|
}
|
|
|
|
$operation_hours = $operation_days[$day_of_week]['operating_hours'];
|
|
foreach($operation_hours as $operation_hour){
|
|
if($operation_time >= $operation_hour['start_time'] && $operation_time <= $operation_hour['end_time']){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
?>
|