In my controller I bring the date of an element with created_at this returns an array with the dates in my database, I need to validate if within this data array is the 07th month or not. My problem is that pru brings me the month 1 if I make a dd and if I bring the year it brings me 1970, it makes me validate one of the elements of the circle if in the function strto time in the date array I put an element like dates [ 0] but only one, I need you to validate in all. This is the code that I am implementing:
public function index()
{
$dates = DB::table('stocks')->pluck('created_at');
foreach($dates as $date){
$pru = date("m", strtotime($dates));
$pru2 = collect($pru);
// dd($pru);
if($pru2->contains('07')){
dd("si tiene Julio");
}else{
dd("no tiene Julio");
}
}
return view('chartjsprueba')->with([
'stocks', $stocks,
'fecha', $fecha
]);
}
How can you validate the month in all the elements of the $ dates array?