F
Filament8mo ago
NolanN

Branding a panel with tenant info

I was hoping to use a tenants name, logo, color, etc for the branding of a panel but the tenant hasn't been identified by that point. I was hoping that the new multi-tenant domain updates might make that possible but it doesn't appear so. Is there any way to do this currently?
5 Replies
Dennis Koch
Dennis Koch8mo ago
Use a middleware - which runs after identification - and access the current panel via Filament::getCurrentPanel(). I think you should be able to modify the settings
NolanN
NolanNOP8mo ago
Ah, good idea. I'll give that a try. Thanks! This is what I've added to the middleware method on the panel. Everything is working expect for the colors call. Any guess why?
class SetTenantBranding
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (Str::endsWith(request()->getHost(), config('tenancy.central_domains'))) {
$domain = Domain::where('domain', str(request()->getHost())->after('://')->before('.'))->first();
} else {
$domain = Domain::where('domain', request()->getHost())->first();
}

Filament::getCurrentPanel()
->brandName($domain?->tenant->name)
->brandLogo($domain?->tenant->getFilamentWordmarkUrl())
->darkModeBrandLogo($domain?->tenant->getFilamentDarkModeWordmarkUrl())
->favicon($domain?->tenant->getFilamentFaviconUrl())
->colors([
'primary' => Color::Lime,
]);

return $next($request);
}
}
class SetTenantBranding
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (Str::endsWith(request()->getHost(), config('tenancy.central_domains'))) {
$domain = Domain::where('domain', str(request()->getHost())->after('://')->before('.'))->first();
} else {
$domain = Domain::where('domain', request()->getHost())->first();
}

Filament::getCurrentPanel()
->brandName($domain?->tenant->name)
->brandLogo($domain?->tenant->getFilamentWordmarkUrl())
->darkModeBrandLogo($domain?->tenant->getFilamentDarkModeWordmarkUrl())
->favicon($domain?->tenant->getFilamentFaviconUrl())
->colors([
'primary' => Color::Lime,
]);

return $next($request);
}
}
Dennis Koch
Dennis Koch8mo ago
Hm. I remember someone with a similar issue when it came to colors.
NolanN
NolanNOP8mo ago
That was it, thanks!
Want results from more Discord servers?
Add your server