5
I’m trying to create a method that will return the amount of minutes since the last insertion in the bank. That’s the way I did it, but I’m making a mistake:
$now = Carbon::now();
$minutes = LusLeadUpdateStatus::select('created_at')
->orderby ('created_at', 'desc')
->get()
->toArray();
$totalDuration = $minutes->diffInMinutes($now);
(// o erro é aqui, pois dando print_r($minutes) o resultado é algo assim:
[0] => Array
(
[created_at] => 2018-08-30 14:55:35
)
[1] => Array
(
[created_at] => 2018-08-30 14:55:20
)
)
the created_at field is where I have the entry in the database, and it is in date / time format.
Try:
$minutes = LusLeadUpdateStatus::select('created_at')
 ->orderby ('created_at', 'desc')
 ->first()
, and after you initialize$totalDuration
how you’re doing sees the return ofdd($totalDuration);
– Miguel