Do multipanel + multitenancy a thing?

I am trying to make multipanel and multitenancy to work I have 3 panels: - AuthPanelProvider - AdminPanelProvider - CompanyPanelProvider - where the multitenancy reside routes/web.php
use App\Enums\PanelAccessEnum;
use Filament\Facades\Filament;
use Filament\Pages\Dashboard;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
if (! Auth::check()) {
return redirect()->to(Filament::getLoginUrl());
}

$user = Auth::user();

if ($user->hasAdminPanelAccess()) {
return redirect(Dashboard::getUrl(panel: PanelAccessEnum::ADMIN->value));
}

if ($user->hasCompanyPanelAccess()) {

return redirect(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value));
}

return redirect()->to(Filament::getLoginUrl());

});
use App\Enums\PanelAccessEnum;
use Filament\Facades\Filament;
use Filament\Pages\Dashboard;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
if (! Auth::check()) {
return redirect()->to(Filament::getLoginUrl());
}

$user = Auth::user();

if ($user->hasAdminPanelAccess()) {
return redirect(Dashboard::getUrl(panel: PanelAccessEnum::ADMIN->value));
}

if ($user->hasCompanyPanelAccess()) {

return redirect(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value));
}

return redirect()->to(Filament::getLoginUrl());

});
middleware:
class RedirectToProperPanelMiddleware
{
public function handle(Request $request, Closure $next): Response
{
if (! Auth::check()) {
return $next($request);
}

$user = Auth::user();
$currentPanel = $request->segment(1); // Get current panel from URL

// Allow admin to access both admin and company panels
if ($user->hasAdminPanelAccess()) {
if ($currentPanel === PanelAccessEnum::ADMIN->value || $currentPanel === PanelAccessEnum::COMPANY->value) {
return $next($request);
}
}

// Company users can only access company panel
if ($user->hasCompanyPanelAccess()) {
if ($currentPanel === PanelAccessEnum::COMPANY->value) {
return $next($request);
}

return redirect()->to(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value));
}

// If no proper access, redirect to login
return redirect()->to(Filament::getLoginUrl());
}
}
class RedirectToProperPanelMiddleware
{
public function handle(Request $request, Closure $next): Response
{
if (! Auth::check()) {
return $next($request);
}

$user = Auth::user();
$currentPanel = $request->segment(1); // Get current panel from URL

// Allow admin to access both admin and company panels
if ($user->hasAdminPanelAccess()) {
if ($currentPanel === PanelAccessEnum::ADMIN->value || $currentPanel === PanelAccessEnum::COMPANY->value) {
return $next($request);
}
}

// Company users can only access company panel
if ($user->hasCompanyPanelAccess()) {
if ($currentPanel === PanelAccessEnum::COMPANY->value) {
return $next($request);
}

return redirect()->to(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value));
}

// If no proper access, redirect to login
return redirect()->to(Filament::getLoginUrl());
}
}
I am using this as the guide/reference: https://filamentexamples.com/tutorial/multiple-panels-sign-in-via-one-sign-in-page
Filament Examples
Filament Multiple Panels: Single Login Page for Admin/User Roles
Having multiple panels is excellent for separating users from other roles. However, managing each different login page can be tricky. So, let's make one login page for all panels and switch redirects based on roles.
Solution:
Dashboard::getUrl has a "tenant" parameter something like this... but use your own tenant value
```php return redirect()->to(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value, tenant: $user->company ));...
Jump to solution
3 Replies
Lucky0
Lucky0OP4d ago
the error: Missing required parameter for [Route: filament.company.pages.dashboard] [URI: company/{tenant}] [Missing parameter: tenant].
Solution
bogus
bogus3d ago
Dashboard::getUrl has a "tenant" parameter something like this... but use your own tenant value
return redirect()->to(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value, tenant: $user->company ));
return redirect()->to(Dashboard::getUrl(panel: PanelAccessEnum::COMPANY->value, tenant: $user->company ));
Lucky0
Lucky0OP3d ago
Sire, thank you

Did you find this page helpful?