[Vuejs]-I cannot get the totals to output properly on the event list

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).

Leave a comment