Virgilio’s answer should solve your problem, but I’m going to leave my answer with a little differential you might need. Let’s assume you need to list the birthday of the month and day in the same function. Then you can do this using the function when
Laravel. So if you don’t pass the birthday parameter of the day, it will list only the one of the month.
// Você pegará o parâmetro da sua request
$aniversariantesDoDia = $request->input( 'aniversariantesDoDia', null);
$aniversariantesDoMes = Pessoa::whereMonth('dt_nasc', Carbon::now()->month)
->when( $aniversariantesDoDia, function ( $query ) use ( $aniversariantesDoDia ) {
return $query->whereDay( 'dt_nasc', $aniversariantesDoDia );
})
->orderByRaw('day(dt_nasc) asc')->get();
whereDate
in place ofwhereMonth
?– Ricardo Pontual
I have tried with whereDate , then returns me an empty list
– Carlos Farias