In my Laravel-5.8, I am returning National Holidays as json request:
Controller:
$nationalholidays = HrHolidayDate::select('holiday_date')
->whereYear('created_at', '=', date('Y'))
->get()
->map(function ($nationalholiday) {
return DateTime::createFromFormat('Y-m-d h:i:s', $nationalholiday->holiday_date)
->format('Y-m-d');
});
return response()->json([
'nationalholidays' => $nationalholidays,
]);
In the view blade, I have console.log(nationalholidays); as:
create:770 (2) ["2021-03-24", "2021-07-08"]0: "2021-03-24"1: "2021-07-08"length: 2__proto__: Array(0)
How do I change it into something like this:
natDays = [
[1, 26], [2, 6], [3, 17],
[4, 27], [5, 25], [6, 6],
[7, 4], [8, 17], [9, 7],
[10, 1], [11, 22], [12, 12]
];
So that it will consist of day and month separated by comma?
I want to use the reqult in jQuery-UI datepicker as shown here:
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1
&& date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}