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';
        });
    }

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'),
    ]
);
Was this page helpful?