Skip to content

Commit aa1e5ab

Browse files
committed
Update readme
1 parent 53f12dd commit aa1e5ab

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ Get the user's last login information:
109109
```php
110110
User::find(1)->lastLoginAt();
111111

112+
User::find(1)->lastSuccessfulLoginAt();
113+
112114
User::find(1)->lastLoginIp();
115+
116+
User::find(1)->lastSuccessfulLoginIp();
113117
```
114118

115119
Get the user's previous login time & IP address (ignoring the current login):

src/Traits/AuthenticationLoggable.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@ public function lastLoginAt()
2121
return optional($this->authentications()->first())->login_at;
2222
}
2323

24+
public function lastSuccessfulLoginAt()
25+
{
26+
return optional($this->authentications()->whereLoginSuccessful(true)->first())->login_at;
27+
}
28+
2429
public function lastLoginIp()
2530
{
2631
return optional($this->authentications()->first())->ip_address;
2732
}
2833

34+
public function lastSuccessfulLoginIp()
35+
{
36+
return optional($this->authentications()->whereLoginSuccessful(true)->first())->ip_address;
37+
}
38+
2939
public function previousLoginAt()
3040
{
3141
return optional($this->authentications()->skip(1)->first())->login_at;

0 commit comments

Comments
 (0)