fetch all months data in laravel code example
Example 1: fetch data based on month and year in laravel
$date = Carbon::createFromFormat('d/m/Y', $request->salary_date);
$empsalaries = EmpSalary:: whereMonth('salary_date', $date->month)
->whereYear('salary_date', $date->year)
->get()
Example 2: fetch data based on month and year in laravel
$post = Mjblog::whereYear('created_at', '=', $year)
->whereMonth('created_at', '=', $month)
->get();