F
FilamentNolanN

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?
DK
Dennis Koch12d 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
N
NolanN12d 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);
}
}
DK
Dennis Koch12d ago
Hm. I remember someone with a similar issue when it came to colors.
N
NolanN12d ago
That was it, thanks!
Want results from more Discord servers?
Add your server
More Posts
Enable Echo.js without breaking Hot ReloadOk I'm at my wit's end here... I know this is probably not strictly Filament related, but maybe therTextEntry when value is null```php TextEntry::make('strap') ->columnSpanFullfilament tabs from blade dont have contentHow can I add content to the tabs directly from blade? As it is now, Its just the tab items themselvHow do I make the bar chart widget to take the full height here?Listener on *resource* (not page)I know listeners on Pages are easy enough - but I can't get them to work on a resource. Essentially Why is this bad? Sending export completion notification to the UI as well as to the database.I played around with the built in filament/packages/actions/src/Exports/Jobs/ExportCompletion.php haCall $livewire->js in header actions?I have this table action which just opens a link with a token, it uses the livewire component to exesticky table headerHello, I've searched this question here and all the solutions did not work, they did do something buDateTimePicker not working hourFormat propertyI'm trying to develop my page with a DateTimePicker able to switch between AM/PM hours, a 12hr formaHow to get data from custom Livewire component that is part of form?I have this Livewire component in my form in an action. How can I get data from that Livewire componRelationManager table action not workingIn a `RelationManager`, the following action works as a header action, but not as a row action. ClicUnderstanding the DatabaseNotificationsSent event. Not seeing websocket notifications in admin panelI have Echo and Soketi running for real time notifications, where I want to dispatch filaments builtHow to enforce client loads newest theme.css?We build the theme CSS on each deploy. How can we tell clients to ignore local cache, and load the nWhat to use: Repeater or Key-valueI have checked the docs of both repeater and key-value form builder fields. I liked both. I am confReferenceError: selectedRows is not definedI have a custom filament page. Super simple: an infolist and a table ``` <x-filament-panels::page> Macro is not working when testing with PestHello all I am using this plugin https://github.com/outer-web/filament-translatable-fields and when Why the authenticate rateLimit &throttled not work ?Why the authenticate rateLimit &throttled not work ?TextColumn action->button not working as expected```php Tables\Columns\TextColumn::make('asdas') ->label('See 2 items') ->action( Tab