Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to read property \"id\" on null src\\App\\Http\\Traits\\ActivityLogger.php:29 #149

Open
alnouirah opened this issue Jan 16, 2023 · 0 comments

Comments

@alnouirah
Copy link

alnouirah commented Jan 16, 2023

Hi all ,
first love the work you have done ♥.


PHP : 8.1
Laravel : 9.44.0
Laravel-logger : 6.0

$userId = Request::user()->{$userIdField};

is there any reason by using Request::user()->{$userIdField} instead of Auth::user()->{$userIdField} ?
because when i am donig Auth::login($user) it throw the exception attempt to read property id on null ?.
i think the reason for that is because i am runing Auth::login($user) from a schedual and there is no request binding for the user 🤔.

I have solve it in tow way :

  • the first way by changing Request::user()->{$userIdField} to Auth::user()->{$userIdField} inside vendor file. and i dont really know the consequnces !

  • the other way by using the following code:

$request->setUserResolver(function () {
                    return $user;
                });

if there is no side effects of using Auth::user()->{$userIdField} I am more than happy to make a pull request 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant