F
Filament7mo ago
NolanN

Getting a 404 when trying to register a tenant

I'm trying to enable the tenant registration feature in one of my panels but I'm getting a 404 when I try to access the page: No query results for model [App\Models\Customer] new Here is the code from my panel:
public function panel(Panel $panel): Panel
{
return $panel->id('customer')
->tenant(Customer::class)
->tenantRegistration(RegisterCustomer::class)
...
}
public function panel(Panel $panel): Panel
{
return $panel->id('customer')
->tenant(Customer::class)
->tenantRegistration(RegisterCustomer::class)
...
}
The route is listed as expected: GET|HEAD app/new .................... filament.customer.tenant.registration › App\Filament\Customer\Pages\RegisterCustomer Any idea why there is a query being made for this customer model?
10 Replies
awcodes
awcodes7mo ago
Because it’s your tenant. And with tenancy it has to query for it in order to scope the app.
NolanN
NolanNOP7mo ago
I'm not following. Shouldn't the app/new route be exempt from looking up a tenant (the Customer model in my case)? I would assume that using the tenantRegistration method would prevent a lookup from happening I get that the app needs to be scoped but I should be able to create new tenants also
awcodes
awcodes7mo ago
in that case you would create a different panel that doesn't use tenancy, then you could have a tenant resource on that panel.
NolanN
NolanNOP7mo ago
It isn't entirely clear but I've assumed that the example has the RegisterTeam class being added to a TeamPanelProvider. If that assumption is correct, I shouldn't have to create a different panel for the sake of creating tenants.
awcodes
awcodes7mo ago
Right, but that registration page is for users to create a tenant if they are not already part of one. If you need a way for an administrator to create tenants then you’ll need a page / panel that isn’t scoped by the tenant middleware.
NolanN
NolanNOP7mo ago
...that registration page is for users to create a tenant...
Yes, that is what I'm trying to do. I think I might have sorted it out but not entirely sure what I changed just yet
awcodes
awcodes7mo ago
Ah, ok. Sorry. I was misunderstanding.
NolanN
NolanNOP7mo ago
No worries. It still helpful just to have a response 🙂 I'm really not sure what changed directly with this but I did upgrade from 3.2.55 -> 3.2.71 and utilized the new afterRegister hook to set a role on the user. It seems like that might have fixed something?
awcodes
awcodes7mo ago
Entirely possible. Could have even been a bug in that particular version that was patch in .56 Glad you got it working though. A lot can happen to 20 patch versions though. Lol.
Want results from more Discord servers?
Add your server