0👍
Assuming $new_activities = [];
is a Collection. (If it’s an array collect($array)
to turn it into collection).
You can utilize map()
to add a field or override an existing field.
$activities->map(function($activity) {
$the_date = strtotime($activity['since']);
if($the_date == strtotime('today UTC')) {
$activity['formatted_date'] = "Today ". $the_date;
} elseif ($the_date == strtotime('yesterday UTC')) {
$activity['formatted_date'] = "Today ". $the_date;
} else {
$activity['formatted_date'] = $the_date;
}
return $activity;
})
Now check the result with dd($activities)
.
- [Vuejs]-How can I destroy Three.js instance
- [Vuejs]-Vuex state change doe not refresh the Vue on Web
Source:stackexchange.com