initial project
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user