Missing tenant parameter on routes

Hi, I'm trying to setup a profile page that lives within the application layout. In order to do this, I'm extending the EditProfile class, and trying to set the layout as the index, instead of the simple one. However, as soon as I try to do this, I get the error: Missing required parameter for [Route: filament.admin.pages.dashboard] [URI: admin/{tenant}] [Missing parameter: tenant]. Any ideas? I had the same issue when trying to setup the Spotlight package.
20 Replies
Patrick Boivin
Patrick Boivinā€¢15mo ago
Can you share your custom EditProfile class?
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
commented out stuff breaks the routing:
<?php

namespace App\Filament\Pages\Auth;

use Filament\Panel;
use Filament\Forms\Form;
use Filament\Facades\Filament;
use Illuminate\Support\Facades\Route;
use Filament\Pages\Auth\EditProfile as BaseEditProfile;

class EditProfile extends BaseEditProfile
{
protected static string $view = 'filament.pages.auth.edit-profile';

// TODO: figure out embedding the profile page in the dashboard layout, getting the tenant issue.
// protected static string $layout = 'filament-panels::components.layout.index';

// public static function getSlug(): string
// {
// return static::$slug ?? 'test';
// }

// public static function routes(Panel $panel): void
// {
// $slug = static::getSlug();
// // $tenant = Filament::getTenant()->id;
// // dd($tenant);

// Route::get("/{tenant}/{$slug}", static::class)
// ->middleware(static::getRouteMiddleware($panel))
// ->withoutMiddleware(static::getWithoutRouteMiddleware($panel))
// ->name('profile');
// }

public function form(Form $form): Form
{
return $form
->schema([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
]);
}
}
<?php

namespace App\Filament\Pages\Auth;

use Filament\Panel;
use Filament\Forms\Form;
use Filament\Facades\Filament;
use Illuminate\Support\Facades\Route;
use Filament\Pages\Auth\EditProfile as BaseEditProfile;

class EditProfile extends BaseEditProfile
{
protected static string $view = 'filament.pages.auth.edit-profile';

// TODO: figure out embedding the profile page in the dashboard layout, getting the tenant issue.
// protected static string $layout = 'filament-panels::components.layout.index';

// public static function getSlug(): string
// {
// return static::$slug ?? 'test';
// }

// public static function routes(Panel $panel): void
// {
// $slug = static::getSlug();
// // $tenant = Filament::getTenant()->id;
// // dd($tenant);

// Route::get("/{tenant}/{$slug}", static::class)
// ->middleware(static::getRouteMiddleware($panel))
// ->withoutMiddleware(static::getWithoutRouteMiddleware($panel))
// ->name('profile');
// }

public function form(Form $form): Form
{
return $form
->schema([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
]);
}
}
Patrick Boivin
Patrick Boivinā€¢15mo ago
Not sure I understand, do you need this page to be scoped to a tenant?
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
I don't. I just need to render the profile page within the entire app's layout, not in a different (simple) layout. So have the sidebar, the nav, etc. ā˜ļø That would work if tenancy wasn't in the app I had the exact same issue when setting up the Spotlight plugin. The way I'm using tenancy is maybe a bit different, my dashboard has several "projects". I use tenancy to keep track of the "active project".
Patrick Boivin
Patrick Boivinā€¢15mo ago
Hmm ok. I still don't really understand why the default EditProfile doesn't work in your case.
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
default does work. It's when I add this line that it doesn't:
protected static string $layout = 'filament-panels::components.layout.index';
protected static string $layout = 'filament-panels::components.layout.index';
Patrick Boivin
Patrick Boivinā€¢15mo ago
Ok sorry, I missed this part
I just need to render the profile page within the entire app's layout
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
Ofc no worries šŸ˜„
Patrick Boivin
Patrick Boivinā€¢15mo ago
So if I'm following correctly, using the regular layout with the EditProfile page is giving you this error about the Dashboard?
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
So, the default EditProfile class renders this view (taken from the vendor):
<x-filament-panels::page.simple>
<x-filament-panels::form wire:submit="save">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page.simple>
<x-filament-panels::page.simple>
<x-filament-panels::form wire:submit="save">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page.simple>
. The view uses the page.simple panel layout. That's why it renders without the application layout (sidebar, etc). With that line that breaks the app:
// protected static string $layout = 'filament-panels::components.layout.index';
// protected static string $layout = 'filament-panels::components.layout.index';
what I'm doing is basically changing the layout to use the application layout (including the sidebar, etc). But that's the issue, I can't extend that layout :/ and the error that's outputted is the following:
Missing required parameter for [Route: filament.admin.pages.dashboard] [URI: admin/{tenant}] [Missing parameter: tenant].
Missing required parameter for [Route: filament.admin.pages.dashboard] [URI: admin/{tenant}] [Missing parameter: tenant].
. I've tried playing around with the routes, so there's a routes method in the EditProfile class:
public static function routes(Panel $panel): void
{
$slug = static::getSlug();
// $tenant = Filament::getTenant()->id;
// dd($tenant);

Route::get("/{tenant}/{$slug}", static::class)
->middleware(static::getRouteMiddleware($panel))
->withoutMiddleware(static::getWithoutRouteMiddleware($panel))
->name('profile');
}
public static function routes(Panel $panel): void
{
$slug = static::getSlug();
// $tenant = Filament::getTenant()->id;
// dd($tenant);

Route::get("/{tenant}/{$slug}", static::class)
->middleware(static::getRouteMiddleware($panel))
->withoutMiddleware(static::getWithoutRouteMiddleware($panel))
->name('profile');
}
but tried a few things and couldn't get it to work :/
Patrick Boivin
Patrick Boivinā€¢15mo ago
dd($tenant) is probably returning null here, right?
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
yeah that's right!
Patrick Boivin
Patrick Boivinā€¢15mo ago
Do you think you can make a custom page instead of using the default EditProfile? It shouldn't be too complicated to re-create it as a regular page with the regular layout?
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
yeah sure thing, that could work indeed. However I'm still unsure as to why it's happening, do you have any ideas?
Patrick Boivin
Patrick Boivinā€¢15mo ago
So the profile page exists outside of tenancy (ie. /admin/profile), and that works fine using the Simple layout. But when you switch to the regular layout, and the rest of your Panel is using tenancy, it needs to know the current tenant to generate all the links in the sidebar (for example the Dashboard at /admin/4). It fails because it doesn't know it should put 4 when it's generating the URL to the dashboard, because the profile has no reference to the tenant. Try this in your EditProfile, you'll see what I mean:
public function mount(): void
{
Filament::setTenant(Team::find(4)); // put your current tenant id here

parent::mount();
}
public function mount(): void
{
Filament::setTenant(Team::find(4)); // put your current tenant id here

parent::mount();
}
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
Ah that makes sense I guess! Thanks for the clarification. Do you know if it's some kinda know issue, or an issue at all? Would be nice to have a property to bypass/overwrite that šŸ™‚
Patrick Boivin
Patrick Boivinā€¢15mo ago
Well I think the short answer is that the Profile page is not designed to use the index layout, hehe
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
Yeah got that haha. I did have the same issue trying to setup the Spotlight plugin tho!
Patrick Boivin
Patrick Boivinā€¢15mo ago
It's possible that there's a simple solution... I can't quite think of it. But this hack with setTenant() should work. You just need to figure out how to store the current tenant in the session. If that makes sense.
Kanalaetxebarria
KanalaetxebarriaOPā€¢15mo ago
Right, makes sense. Thanks for the help!
Want results from more Discord servers?
Add your server