@@ -78,13 +78,13 @@ public function attemptLockout(string $id, object $data): bool
7878
7979 public function attemptSendLockoutNotification (string $ id , object $ data ): void
8080 {
81- // When the use disable the unlock via notification feature
81+ // When the user disables the unlock via notification feature
8282 // we can skip sending the notification
8383 if (!$ this ->unlockViaNotification ) {
8484 return ;
8585 }
8686
87- // Check also if the column is a valid email format
87+ // Check also if the identifier is a valid email format
8888 if (!filter_var ($ id , FILTER_VALIDATE_EMAIL )) {
8989 return ;
9090 }
@@ -99,10 +99,8 @@ public function attemptSendLockoutNotification(string $id, object $data): void
9999
100100 $ notification = new $ notificationClass ($ id , $ this ->decayMinutes , $ signedUnlockUrl );
101101
102- $ model = ModelLockout::active ()
103- ->where ('identifier ' , $ id )
104- ->first ()?->model;
105-
102+ // Resolve the login model using the single-model strategy configured in auth.providers.users.model
103+ $ model = $ this ->getLoginModel ($ id );
106104 if (!$ model ) {
107105 return ;
108106 }
@@ -119,6 +117,20 @@ public function getLoginField(): string
119117 return config ('lockout.login_field ' , 'email ' );
120118 }
121119
120+ public function getLoginModelClass (): string
121+ {
122+ $ loginField = $ this ->getLoginField ();
123+
124+ return config ('auth.providers.users.model ' );
125+ }
126+
127+ public function getLoginModel (string $ identifier ): ?Model
128+ {
129+ $ modelClass = $ this ->getLoginModelClass ();
130+
131+ return $ modelClass ::where ($ this ->getLoginField (), $ identifier )->first ();
132+ }
133+
122134 protected function throttleKey (string $ id ): string
123135 {
124136 return 'login-attempts: ' . $ id ;
@@ -148,6 +160,18 @@ protected function createLog(string $id, object $data): void
148160 $ logModel ->user_agent = $ data ->user_agent ?? null ;
149161 $ logModel ->attempted_at = now ();
150162
163+ // Attempt to associate the created log with the configured login model
164+ // (single-model strategy). Be defensive: swallow any errors so tests and
165+ // constrained environments without the users table do not fail.
166+ try {
167+ $ model = $ this ->getLoginModel ($ id );
168+ if ($ model instanceof Model) {
169+ $ logModel ->model ()->associate ($ model );
170+ }
171+ } catch (\Throwable $ _ ) {
172+ // ignore association failures
173+ }
174+
151175 $ logModel ->save ();
152176 }
153177}
0 commit comments