filament icon indicating copy to clipboard operation
filament copied to clipboard

Custom `EditProfile` page in multi-tenancy causes `Missing required parameter`

Open johncarter- opened this issue 3 years ago • 9 comments

Package

filament/filament

Package Version

v3.0.91

Laravel Version

v10.30.1

Livewire Version

v3.1.0

PHP Version

PHP 8.2.13

Problem description

When adding a custom EditProfile screen to a panel with multi-tenancy, a missing required tenant parameter causes the tenant registration page to trigger an exception.

Expected behavior

When you visit a panel route without a tenant it should gracefully fail somehow. You can't create a team without a team if you have a custom EditProfile page created within the panel.

Steps to reproduce

  1. Seed the database in the demo repo
  2. Visit http://localhost/app
  3. See the Missing required parameter for [Route: filament.app.pages.edit-profile] [URI: app/{tenant}/edit-profile] [Missing parameter: tenant].

Reproduction repository

https://github.com/johncarter-/filament-demo/tree/issue/tenant-create-edit-profile

Relevant log output

No response

johncarter- avatar Nov 28 '23 10:11 johncarter-

I understand that this is could be considered not necessarily a bug and understand you way want to close it. But i believe it to be important for others to find should they run into the same issue.

The problem lies in having the EditProfile class extend a Filament\Pages\Page when I think it has to extend a Filament\Pages\SimplePage.

johncarter- avatar Nov 28 '23 11:11 johncarter-

You are not extending Filament's EditProfile page, you're extending the base class?

danharrin avatar Nov 28 '23 13:11 danharrin

Well I wanted the profile page to use the same layout (nav, etc) and styling as one of my panels, so this seemed the logical choice.

It seems that panel layouts with a null tenant seem to be a no-no - right?

johncarter- avatar Nov 28 '23 13:11 johncarter-

The reason why it's outside of the "tenant" area is because otherwise, a user without tenants wouldnt be able to access their profile, as the sidebar is required to render that layout

danharrin avatar Nov 28 '23 13:11 danharrin

There isn't stopping you from using make:filament-page and creating the profile page like a normal custom page, but you won't use $panel->profile() and instead add the link to the user menu manually

danharrin avatar Nov 28 '23 13:11 danharrin

Thanks Dan, I'll give that a go. If I have success I'll update this issue. Feel free to close.

johncarter- avatar Nov 28 '23 13:11 johncarter-

Gonna close this as I think that solved the problem for you.

danharrin avatar Dec 12 '23 19:12 danharrin

What solved my problem form in filament multi-tenacy was instead of extending Filament\Pages\Auth\EditProfile instead use Filament\Pages\Tenancy\EditTenantProfile it works

bethwelt avatar Jan 05 '25 06:01 bethwelt

For anyone else looking I figured this out and it might help... It looks like the intended method is to set your profile page as simple page by passing the argument to the ->profile method like so:

->profile(EditProfile::class, true)

This will make the profile page come in a simplePage view getting rid of any of the Tenant parameter requirements. You only need to account for any menu items you might have configured in your panel.

'MyItem' => MenuItem::make()
     ->label('MyItem')
     ->hidden(fn(): bool => Filament::getTenant() === null)  // <--- this will keep the menu item from rendering when a tenant is not identifiable
     ->url(fn(): string => route('filament.pages.myitem', Filament::getTenant()))

jgarvey-dev avatar Mar 25 '25 00:03 jgarvey-dev