i have a date
with format Y-m-d
. How can i filter it by month? I specified the month by numbers like January = 1, February = 2
and so and so forth.
public function scopegetmonthleavereport($query,$payroll_employee_id,$month)
{
$query->join('tbl_payroll_leave_employee_v2','tbl_payroll_leave_schedulev2.payroll_leave_employee_id','=','tbl_payroll_leave_employee_v2.payroll_leave_employee_id')
->join("tbl_payroll_employee_basic","tbl_payroll_leave_employee_v2.payroll_employee_id","=","tbl_payroll_employee_basic.payroll_employee_id")
->join("tbl_payroll_leave_tempv2","tbl_payroll_leave_employee_v2.payroll_leave_temp_id","=","tbl_payroll_leave_tempv2.payroll_leave_temp_id")
->select(DB::raw('tbl_payroll_employee_basic.payroll_employee_id , tbl_payroll_leave_schedulev2.payroll_schedule_leave, tbl_payroll_employee_basic.payroll_employee_display_name, tbl_payroll_leave_schedulev2.payroll_leave_temp_with_pay, tbl_payroll_leave_tempv2.payroll_leave_type_id, tbl_payroll_leave_employee_v2.payroll_leave_employee_id, tbl_payroll_leave_schedulev2.consume, tbl_payroll_leave_employee_v2.payroll_leave_temp_hours, sum(tbl_payroll_leave_schedulev2.consume) as total_leave_consume, (tbl_payroll_leave_employee_v2.payroll_leave_temp_hours - sum(tbl_payroll_leave_schedulev2.consume)) as remaining_leave'))
->groupBy('tbl_payroll_leave_employee_v2.payroll_leave_temp_id')
->where('tbl_payroll_leave_schedulev2.payroll_leave_schedule_archived',0)
->where('tbl_payroll_leave_employee_v2.payroll_employee_id', $payroll_employee_id)
->whereBetween('tbl_payroll_leave_schedulev2.payroll_schedule_leave', $date); //where i want to put the date
return $query;
}