File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,6 +242,17 @@ public function getPasswordHash(): ?string
242242 return $ this ->password_hash ;
243243 }
244244
245+ /**
246+ * Returns the previous login information for this user
247+ */
248+ public function previousLogin (): ?Login
249+ {
250+ /** @var LoginModel $logins */
251+ $ logins = model (LoginModel::class);
252+
253+ return $ logins ->previousLogin ($ this );
254+ }
255+
245256 /**
246257 * Returns the last login information for this user as
247258 */
Original file line number Diff line number Diff line change @@ -67,6 +67,19 @@ public function recordLoginAttempt(
6767 $ this ->checkQueryReturn ($ return );
6868 }
6969
70+ /**
71+ * Returns the previous login information for the user,
72+ * useful to display to the user the last time the account
73+ * was accessed.
74+ */
75+ public function previousLogin (User $ user ): ?Login
76+ {
77+ return $ this ->where ('success ' , 1 )
78+ ->where ('user_id ' , $ user ->id )
79+ ->orderBy ('id ' , 'desc ' )->get ()
80+ ->getRow (1 , Login::class);
81+ }
82+
7083 /**
7184 * Returns the last login information for the user
7285 */
You can’t perform that action at this time.
0 commit comments