I'm trying to get the latest shield login.
I do the following:
PHP Code:
$tmpUser = auth()->getProvider();
$user = $tmpUser->findById($users[$i]->id);
$lastLogin = $user->lastLogin();
$tmp = $lastLogin->toArray();
echo'<pre>';print_r($tmp['date']->format('Y-m-d H:i'));echo'</pre>';
d($tmp['date']->format('Y-m-d H:i'));exit();
This returns me:
But when I want to save it to an array:
PHP Code:
$tmpUser = auth()->getProvider();
$user = $tmpUser->findById($users[$i]->id);
$lastLogin = $user->lastLogin();
$tmp = $lastLogin->toArray();
$userList[] = [
'id' => $users[$i]->id,
'user' => $users[$i]->username,
'grupos' => $grupo,
'lastLogin' => $tmp['date']->format('Y-m-d H:i'),
it returns me this error:
and I don't understand why with d or print_r/var_dump it prints the value, but I can't assign it to the array