© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Vincent

Removing tenant parameter and middleware for SimplePage

Hi!

In the app I'm building, users can belong to multiple tenants.

I'm tracking their current organization via a
currentOrganization
currentOrganization
relationship on the User model.

If a user's current org is empty, I'd like to redirect them to a page,
/current-organization
/current-organization
, where they can select which of their organizations they'd like to administer. I'm doing this via middleware:

// EnsureUserHasCurrentOrganization middleware
if (
    ! $user->current_organization_id
    && $user->organizations()->exists()
) {
    return redirect(
        '/current-organization',
        Response::HTTP_FOUND
    );
}
// EnsureUserHasCurrentOrganization middleware
if (
    ! $user->current_organization_id
    && $user->organizations()->exists()
) {
    return redirect(
        '/current-organization',
        Response::HTTP_FOUND
    );
}


and
/current-organization
/current-organization
:

class CurrentOrganization extends SimplePage
{
    use HasRoutes;

    protected static string $view = 'filament.pages.current-organization';

    public static function routes(Panel $panel): void
    {
        $slug = static::getSlug();

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

    public static function getWithoutRouteMiddleware(Panel $panel): string|array
    {
        return [
            ...Arr::wrap(static::$withoutRouteMiddleware),
            EnsureUserHasCurrentOrganization::class,
        ];
    }
}
class CurrentOrganization extends SimplePage
{
    use HasRoutes;

    protected static string $view = 'filament.pages.current-organization';

    public static function routes(Panel $panel): void
    {
        $slug = static::getSlug();

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

    public static function getWithoutRouteMiddleware(Panel $panel): string|array
    {
        return [
            ...Arr::wrap(static::$withoutRouteMiddleware),
            EnsureUserHasCurrentOrganization::class,
        ];
    }
}


This page is registered via the
pages
pages
method in the Panel Provider.

There are two problems:

1. The route above still appears in the
{tenant}
{tenant}
namespace.
php artisan routes:list | grep current
php artisan routes:list | grep current
shows:
  GET|HEAD   myurl.test/{tenant}/current-organization ... filament.admin.pages.current-organization › App\Filament\Pages\CurrentOrganization
  GET|HEAD   myurl.test/{tenant}/current-organization ... filament.admin.pages.current-organization › App\Filament\Pages\CurrentOrganization

2. It gets stuck in a redirect loop despite explicitly disabling the offending middleware.

Is this a bug, or am I missing something? How can I remove it from the tenant routes? And how can I disable the middleware?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Return SimplePage as response for middleware exception?
FilamentFFilament / ❓┊help
2y ago
Missing parameter {tenant}
FilamentFFilament / ❓┊help
3y ago
Missing Parameter Tenant for Auth Route
FilamentFFilament / ❓┊help
2y ago
[Missing parameter: tenant] On custom tenant page ?
FilamentFFilament / ❓┊help
17mo ago