© 2026 Hedgehog Software, LLC

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

Change AdminPanelProvider primary color through model

I am trying to fetch a color value from a model and use it as a primary color in the AdminPanelProvider, but I ran into issues where I get the error "Call to a member function connection() on null" so I figured it is caused because of the booting order so I tried to fetch the value by adding
    private $brandColor;

    public function register(): void
    {
        parent::register();

        $this->app->booted(function () {
            $this->brandColor = Company::first()->brand_color ?? '#FF6921';
        });
    }
    private $brandColor;

    public function register(): void
    {
        parent::register();

        $this->app->booted(function () {
            $this->brandColor = Company::first()->brand_color ?? '#FF6921';
        });
    }

But when I access $this->brandColor outside the method it returns null, otherwise inside it returns the correct value.

Is this the correct approach to change the primary color through a model and why am I facing this issue, or if I should take another approach if that is possible to do?
Solution
FilamentColor::register(
   [
        'primary' => Color::hex('#ff0099'),
    ]
);
FilamentColor::register(
   [
        'primary' => Color::hex('#ff0099'),
    ]
);
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to change primary color outside admin panel?
FilamentFFilament / ❓┊help
2y ago
Primary Color for v3?
FilamentFFilament / ❓┊help
3y ago
FIlament Blade components outside filament. Change default primary color
FilamentFFilament / ❓┊help
2y ago
Change Color
FilamentFFilament / ❓┊help
2y ago