2 回答
TA贡献1735条经验 获得超5个赞
为什么不覆盖 authController 中的登录方法??????像这样
public function login(Request $request)
{
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if (method_exists($this, 'hasTooManyLoginAttempts') &&
$this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptLogin($request)) {
$user = auth()->guard('web')->user();
//$user = auth()->guard('api')->user();
$user->last_login = now()->toDateTimeString();
$user->save();
return $this->sendLoginResponse($request);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
TA贡献1835条经验 获得超7个赞
最后我可以做到,我在函数句柄中使用 WHERE,具体来说
app\Listeners\UpdateLastSignInAt
<?php
namespace App\Listeners;
use Illuminate\Auth\Events\Login;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Carbon\Carbon;
class UpdateLastSignInAt
{
public function __construct()
{
//
}
public function handle(Login $event)
{
$date = Carbon::now();
$user = $event->user->ID;
User::where('ID', $user)
->update(['LAST_LOGIN' => $date]);
}
}
- 2 回答
- 0 关注
- 177 浏览
添加回答
举报
