Dynamically set the order for the widgets on each page

Is there a way to do so? Or is that not possible yet? I tried adding this method and then call it with the make method, but that didn't work:

Widget class:
    public static function setSort(?int $sort): self
    {
        self::$sort = $sort;

        return new static();
    }


Dashboard.php

protected function getHeaderWidgets(): array
    {
        return $this->page->widgets->filter(function ($widget) {
            return $widget->pivot->position === 'top' || $widget->pivot->position === null;
        })->map(function ($widget) {
            if (method_exists($widget->class, 'make')) {
                return $widget->class::setSort($widget->pivot->order)->make([
                    'width' => $widget->pivot->width,
                ]);
            }
            return null;
        })->filter()->toArray();
    }
Screenshot_2024-05-24_at_10.24.08.png
Was this page helpful?