use whereMonth and whereYear()
May 2, 2023
5
Level 1
how to filter data by month instead of date in laravel?
I am new to laravel and I could filter data by date but I don't know how to filter the same by month. Below is the controller function and views:
public function photo_gallery_show(Request $request) {
$gallery_data = PhotoGallery::when($request->date != null, function ($q) use ($request) {
return $q->whereDate('event_date', $request->date);
})
->paginate(10)
->sortByDesc('event_date');
Select Month:
Filter
return view('front.photo_gallery', compact('gallery_data'));
}
Level 122
1 like
Please or to participate in this conversation.