Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public function handle(Logout $event) |
||
37 | { |
||
38 | if ($event->user) { |
||
39 | $user = $event->user; |
||
40 | $ip = $this->request->ip(); |
||
41 | $userAgent = $this->request->userAgent(); |
||
42 | $authenticationLog = $user->authentications()->whereIpAddress($ip)->whereUserAgent($userAgent)->first(); |
||
|
|||
43 | |||
44 | if (! $authenticationLog) { |
||
45 | $authenticationLog = new AuthenticationLog([ |
||
46 | 'ip_address' => $ip, |
||
47 | 'user_agent' => $userAgent, |
||
48 | ]); |
||
49 | } |
||
50 | |||
51 | $authenticationLog->logout_at = Carbon::now(); |
||
52 | |||
53 | $user->authentications()->save($authenticationLog); |
||
54 | } |
||
57 |