F
Filamentβ€’9mo ago
Arnaud

Tenant admin color

Hello, Do you know a way to get Tenant in Filament Provider in order to have the current Tenant ? The idea behind that is to set a color per Panel I've tried to use the bootUsing method in $panel, but set $panel->colors no update the color ... The problem with AppServiceProvider is I can't get current tenant or even route ...
Solution:
Ok so if anybody wonder how to do that, I've simply created a new middleware : ```` public function handle(Request $request, Closure $next): Response { $tenant = Filament::getTenant();...
Jump to solution
4 Replies
Solution
Arnaud
Arnaudβ€’9mo ago
Ok so if anybody wonder how to do that, I've simply created a new middleware :
public function handle(Request $request, Closure $next): Response
{
$tenant = Filament::getTenant();

if (! $tenant) {
return $next($request);
}

FilamentColor::register([
'primary' => $this->returnColor($tenant->color),
]);

return $next($request);
}

public function returnColor(string $color = 'Sky'): array
{
return constant('Filament\\Support\\Colors\\Color::'.$color);
}
public function handle(Request $request, Closure $next): Response
{
$tenant = Filament::getTenant();

if (! $tenant) {
return $next($request);
}

FilamentColor::register([
'primary' => $this->returnColor($tenant->color),
]);

return $next($request);
}

public function returnColor(string $color = 'Sky'): array
{
return constant('Filament\\Support\\Colors\\Color::'.$color);
}
And add it to ->tenantMiddleware in $panel configuration
Helge Sverre
Helge Sverreβ€’8mo ago
@Arnaud Awesome, just what i was looking for! You saved me hours of fiddling.
No description
Helge Sverre
Helge Sverreβ€’8mo ago
readlly wish i could do this though πŸ˜›
No description
Helge Sverre
Helge Sverreβ€’8mo ago
But i assume there is some technical reason as to why this is not supported out of the box. gonna wrap this up in a blog post for the future