Laravel多租户转换问题

I have a situation. I have an application that has both admin and tenants. In admin we have modules like user management, tenant management etc. In tenants I have user management and some other modules.
In AppServiceProvider I have set the default connection as tenant as mentioned in this link (Only after this the tenant login worked). When I create a tenant via admin, I switch the connection as mentioned in this link to the newly created customer and create a user using the default User Model. This User model is the default one and I have not used the tenant connection trait in this. This created a new user in the tenant database as expected. But when I tried to switch the connection in another controller, the switch did not work until I used another CustomerUser model with the tenant trait. When I used the default User model, the data fetched was from the system. The only difference I found was the code just above the switching, which is,

$website = new Website;
$website->uuid = $customer->domain_name;
app(WebsiteRepository::class)->create($website);
$hostname = new Hostname;
$serverName = $request->server->get('SERVER_NAME');
$hostname->fqdn = $website->uuid.'.'.$serverName;
$hostname = app(HostnameRepository::class)->create($hostname);
app(HostnameRepository::class)->attach($hostname, $website);
return $website->id;

I use this returned website id to switch to the tenant.

But when I tried in the other controller the switching code was same but to get the website I used this code:

$customerWebsite = Customers::findOrFail($customerId)->website;
$uuid = $customerWebsite->uuid;
$website = app(WebsiteRepository::class)->findByUuid($uuid);

The common switch code:

$tenancy = app(Environment::class);
$tenancy->tenant($website);

Please suggest a way to fix the issue.

The following snippet can be used to configure the app:

app(Environment::class)->tenant($hostname->website);
config(['database.default' => 'tenant']);