Loading wrong model on infolist

Hey guys, I found some strange behavior in my app and I can't help it.

I am trying to load all direct children and authenticated user here:
// UserResource.php
    /** @return Builder<User> */
    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()
            ->when(
                auth()->user()->hasRole(UserRole::Broker),
                fn (Builder $query) => $query
                    ->where('parent_id', '=', auth()->id())
                    ->orWhere('id', auth()->id()),
            );
    }

Inside my users table I see 3 users: Parent (auth one), Child 1 and Child 2. When I click on parent or child 1, I see infolist for these models, but when I click on child 2 it still give me infolist with child 1. Although I can see child id 2 in the url.

I am using this package: https://github.com/staudenmeir/laravel-adjacency-list

Can you help point me in the right direction?
GitHub
Recursive Laravel Eloquent relationships with CTEs - staudenmeir/laravel-adjacency-list
Was this page helpful?