Skip to content

Commit b8a5d24

Browse files
authored
Merge pull request #25 from rappasoft/develop
v1.2.1
2 parents 945f0f1 + 88c05b9 commit b8a5d24

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to `Laravel Authentication Log` will be documented in this file.
44

5+
### 1.2.1 - 2021-12-02
6+
7+
### Added
8+
9+
- Added latestAuthentication relationship - https://github.com/rappasoft/laravel-authentication-log/pull/24
10+
11+
### Changed
12+
13+
- Fixed issue with PHP 7.4 - https://github.com/rappasoft/laravel-authentication-log/pull/22
14+
515
### 1.2.0 - 2021-11-21
616

717
### Added

src/LaravelAuthenticationLogServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public function configurePackage(Package $package): void
2727
->hasCommand(PurgeAuthenticationLogCommand::class);
2828

2929
$events = $this->app->make(Dispatcher::class);
30-
$events->listen(config('authentication-log.events.login') ?? Login::class, LoginListener::class);
31-
$events->listen(config('authentication-log.events.failed') ?? Failed::class, FailedLoginListener::class);
32-
$events->listen(config('authentication-log.events.logout') ?? Logout::class, LogoutListener::class);
33-
$events->listen(config('authentication-log.events.other-device-logout') ?? OtherDeviceLogout::class, OtherDeviceLogoutListener::class);
30+
$events->listen(config('authentication-log.events.login', Login::class), LoginListener::class);
31+
$events->listen(config('authentication-log.events.failed', Failed::class), FailedLoginListener::class);
32+
$events->listen(config('authentication-log.events.logout', Logout::class), LogoutListener::class);
33+
$events->listen(config('authentication-log.events.other-device-logout', OtherDeviceLogout::class), OtherDeviceLogoutListener::class);
3434
}
3535
}

src/Listeners/FailedLoginListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public function __construct(Request $request)
1717

1818
public function handle($event): void
1919
{
20-
if (! $event instanceof (config('authentication-log.events.failed') ?? Failed::class)) {
20+
$listener = config('authentication-log.events.failed', Failed::class);
21+
if (! $event instanceof $listener) {
2122
return;
2223
}
2324

src/Listeners/LoginListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public function __construct(Request $request)
1818

1919
public function handle($event): void
2020
{
21-
if (! $event instanceof (config('authentication-log.events.login') ?? Login::class)) {
21+
$listener = config('authentication-log.events.login', Login::class);
22+
if (! $event instanceof $listener) {
2223
return;
2324
}
2425

src/Listeners/LogoutListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public function __construct(Request $request)
1717

1818
public function handle($event): void
1919
{
20-
if (! $event instanceof (config('authentication-log.events.logout') ?? Logout::class)) {
20+
$listener = config('authentication-log.events.logout', Logout::class);
21+
if (! $event instanceof $listener) {
2122
return;
2223
}
2324

src/Listeners/OtherDeviceLogoutListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public function __construct(Request $request)
1717

1818
public function handle($event): void
1919
{
20-
if (! $event instanceof (config('authentication-log.events.other-device-logout') ?? OtherDeviceLogout::class)) {
20+
$listener = config('authentication-log.events.other-device-logout', OtherDeviceLogout::class);
21+
if (! $event instanceof $listener) {
2122
return;
2223
}
2324

src/Traits/AuthenticationLoggable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public function authentications()
1111
return $this->morphMany(AuthenticationLog::class, 'authenticatable')->latest('login_at');
1212
}
1313

14+
public function latestAuthentication()
15+
{
16+
return $this->morphOne(AuthenticationLog::class, 'authenticatable')->latestOfMany('login_at');
17+
}
18+
1419
public function notifyAuthenticationLogVia(): array
1520
{
1621
return ['mail'];

0 commit comments

Comments
 (0)