I'm running a query which returns a collection array with 7 items -
$uniques = Analytics::fetchviews(Period::days(7))->take(7);
The collection results look like this-
2 => array:4 [▼
"date" => Carbon {#247 ▶}
"uniquePageviews" => 1
"pageViews" => 1
]
I would like to take out the pageViews
and uniquePageviews
and work with these integers before passing the results to a view. How can I edit the data within the collection directly?
A collection is just a list of models. You can iterate over them, work with their attributes and so forth. For example:
foreach ($uniques as $unique) {
var_dump($unique->pageViews);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With