I have array an array with this value
array:11 [
"id" => 4
"title" => "CLUSTER AIRING"
"channel_title" => "CLUSTER AIRING"
"parent_id" => 2
"start_date" => "2022-09-30 10:59:00"
"end_date" => "2022-09-30 13:58:00"
"image_url" => "https://stag-sections-image.visionplus.id/media/"
"content_core_id" => 2
"type" => "Channel"
"content_type" => "Channel"
"is_upcoming" => true
]
I already make this code to filter start_date & end_date this filter already works. but when I changed the valueis_upcoming
from true to it's not changed. but when I make dd()
to $item
this is already changed to false. Here is my code
$data = array_values(array_filter($data, function($item){
if (($item['start_date']) <= now() && ($item['end_date'] >= now()) ) {
$item['is_upcoming'] = false;
return $item;
}
if ($item['start_date'] > now()) {
$item['is_upcoming'] = true;
return $item;
}
}));