emi_sastra
asked on
Update Users Tabel Laravel using MS SQL
Hi Experts,
I create a laravel project and using MS SQL database.
Please see these code:
// $user->update([
// 'last_login_at' => Carbon::now()->toDateTimeS tring(),
// 'last_login_ip' => $request->getClientIp()
// ]);
If I uncomment it then it is error.
Please the attachment.
What is wrong?
Thank you.
Error-update-users-table.PNG
I create a laravel project and using MS SQL database.
protected function authenticated(Request $request, $user)
{
// $user->update([
// 'last_login_at' => Carbon::now()->toDateTimeString(),
// 'last_login_ip' => $request->getClientIp()
// ]);
// Check to see if the users account is confirmed and active
if (! $user->isConfirmed()) {
auth()->logout();
// If the user is pending (account approval is on)
if ($user->isPending()) {
throw new GeneralException(__('exceptions.frontend.auth.confirmation.pending'));
}
// Otherwise see if they want to resent the confirmation e-mail
throw new GeneralException(__('exceptions.frontend.auth.confirmation.resend', ['url' => route('frontend.auth.account.confirm.resend', e($user->{$user->getUuidName()}))]));
}
if (! $user->isActive()) {
auth()->logout();
throw new GeneralException(__('exceptions.frontend.auth.deactivated'));
}
event(new UserLoggedIn($user));
if (config('access.users.single_login')) {
auth()->logoutOtherDevices($request->password);
// Auth::logoutOtherDevices($request->password);
}
return redirect()->intended($this->redirectPath());
}
Please see these code:
// $user->update([
// 'last_login_at' => Carbon::now()->toDateTimeS
// 'last_login_ip' => $request->getClientIp()
// ]);
If I uncomment it then it is error.
Please the attachment.
What is wrong?
Thank you.
Error-update-users-table.PNG
ASKER
Let me see again.
Thank you.
Thank you.
ASKER
I get this with my code.
array:2 [▼
"last_login_at" => "2019-12-05 05:40:13"
"last_login_ip" => "119.235.208.235"
]
Is it okay ?
Thank you.
array:2 [▼
"last_login_at" => "2019-12-05 05:40:13"
"last_login_ip" => "119.235.208.235"
]
Is it okay ?
Thank you.
Yes that it, looks like you're getting the right date and the right client IP address. glad I could help.
ASKER
But, still get the same error.
Thank you.
Thank you.
I don't think so if there's an error you'll not get the array of values as you show us in the previous comment, else the error is in another part of code that is not posted in your OP.
Are you using the createFromFormat function somewhere else in your code?
Are you using the createFromFormat function somewhere else in your code?
ASKER
Some of my friends said that it is ok using MySQL.
The Last_login_IP is work properly, after I comment the last_login_at.
Thank you.
The Last_login_IP is work properly, after I comment the last_login_at.
Thank you.
ASKER
The problem is at date column.
Thank you.
Thank you.
ASKER
Hi Zakarian,
I use your code, and get trailing data.
Thank you.
I use your code, and get trailing data.
Thank you.
Could you please explain more what you mean by trailing data?
ASKER
I change last_login_at to varchar(50).
the error at the attachment.
Thank you.
the error at the attachment.
Thank you.
ASKER
Please see the error.
Error-update-users-table-1.PNG
Error-update-users-table-1.PNG
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
By :Open in new window
And try again.