Skip to content

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

Open
@alnouirah

Description

@alnouirah

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 😄.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions