$rankArray = [
'ranks' => $product[0]['productSalesRank']->pluck('rank'),
'dates' => $product[0]['productSalesRank']->pluck('created_at')
];
$rankArray['dates']->transform(function ($item) {
return $item->format('d-m-Y');
});
Having to transform everytime I retrieve the created_at/updated_at date from the database seems so inefficient, is there a simplier way of doing this?
I want to keep the date as Carbon, but in some instances, do just want the "value"