Closed ziming closed 3 weeks ago
Hello, BusinessTime::enable
set the default config, but Schedule::create()
is a way to isolate a config, so both won't merge.
You can either include 'region' => 'sg-national'
in your Schedule
:
$schedule = Schedule::create([
'friday' => [
'10:00-18:00',
],
'monday' => [
'10:00-18:00',
],
'sunday' => [],
'tuesday' => [
'10:00-18:00',
],
'saturday' => [],
'thursday' => [
'10:00-18:00',
],
'wednesday' => [
'10:00-18:00',
],
'exceptions' => [],
'holidaysAreClosed' => true,
'holidays' => [
'region' => 'sg-national',
],
]);
var_dump($schedule->isOpenOn('2024-12-25')); // false
Or you pass the planning in default settings and use Carbon
:
BusinessTime::enable(Carbon::class, [
'friday' => [
'10:00-18:00',
],
'monday' => [
'10:00-18:00',
],
'sunday' => [],
'tuesday' => [
'10:00-18:00',
],
'saturday' => [],
'thursday' => [
'10:00-18:00',
],
'wednesday' => [
'10:00-18:00',
],
'exceptions' => [],
'holidaysAreClosed' => true,
'holidays' => [
'region' => 'sg-national',
],
]);
var_dump(Carbon::isOpenOn('2024-12-25'));
I'm not exactly sure when it started happening but it was previous working but now it just seem to return true all the time.
Example code:
1st in a laravel codebase i have something like this in my AppServiceProvider boot method
Then this example code: