I have a collection that I am trying to filter on created_at year. Laravel 5.3. I am trying to use whereYear inside my filter but it's sqwaking that the method is undefined. How do I define it? Or is there a better way?
$datas = Campaign::all();
if($request->year) {
$value = $request->year;
$datas = $datas->filter(function($data) use ($value) {
return $data->created_at->whereYear($value);
});
}
Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire