Update Schedules
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Helper{
|
||||
@@ -33,4 +35,32 @@ class Helper{
|
||||
'next_page_url' => $resource->nextPageUrl(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function dailyAvailabilitiesToDate($dailyAvailabilities, $startDate, $endDate = null) {
|
||||
|
||||
Carbon::setLocale('id');
|
||||
|
||||
$startDate = Carbon::parse($startDate);
|
||||
if ( empty($endDate) ) {
|
||||
$endDate = $startDate;
|
||||
} else {
|
||||
$endDate = Carbon::parse($endDate);
|
||||
}
|
||||
$ranges = CarbonPeriod::create($startDate, $endDate);
|
||||
|
||||
$datesAvailabilities = [];
|
||||
foreach ( $ranges as $date ) {
|
||||
|
||||
$datesAvailabilities[] = [
|
||||
'date' => $date->format('Y-m-d'),
|
||||
'day' => $date->dayName,
|
||||
'slot' => $dailyAvailabilities[$date->dayName],
|
||||
'timezone' => 'WIB'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return $datesAvailabilities;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user