rappasoft / laravel-authentication-log

Log user authentication details and send new device notifications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Model exception

keizah7 opened this issue · comments

I integrated AuthenticationLoggable to 2 model User and Company. AdminUser is without trait but it throws exception in login

image

All models have diff guards but it still throws an error

[2022-01-13 16:55:47] staging.ERROR: Call to undefined method App\Models\AdminUser::authentications() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method App\\Models\\AdminUser::authentications() at /Users/arturas/code/Artme/wil/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:71)
[stacktrace]
#0 /Users/arturas/code/Artme/wil/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(36): Illuminate\\Database\\Eloquent\\Model::throwBadMethodCallException('authentications')
#1 /Users/arturas/code/Artme/wil/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2132): Illuminate\\Database\\Eloquent\\Model->forwardCallTo(Object(Illuminate\\Database\\Eloquent\\Builder), 'authentications', Array)
#2 /Users/arturas/code/Artme/wil/vendor/rappasoft/laravel-authentication-log/src/Listeners/LoginListener.php(30): Illuminate\\Database\\Eloquent\\Model->__call('authentications', Array)

I know you said you included the trait but the fact that it can't find the method would point to the trait not being implemented?

I have 3 authenticable models. One of them don't have your trait and that model doesn't need log, but it still shows error, because package tries to log the authentication even that model, doesn't have that method.

I think code should check if model needs package functionality