Reputation: 11
How can I get all dates that have value in a particular month in Laravel carbon? I tried groupBy
, but it was grouped by months, and I can't fetch the date from a particular month. Below is the sample code. I only fetch the month value, not the dates. My expectation is I want to fetch all dates in a particular month
$fetch_data = Calendar::groupBy('month')->get();
$get_data = array();
foreach ($fetch_data as $holiday => $key) {
$data_events = array(
'id' => $key->id,
'title' => ucwords($key->holiday_title),
'start' => $key->holiday_date
);
array_push($get_data, $data_events);
}
return response()->json($get_data);
Upvotes: 0
Views: 408
Reputation: 3045
Instead of using groupBy
, you might simply add a where
clause:
Calendar::where('month', $month)->get();
Upvotes: 0