public static function orderByPreference($widgets)
    {
        $preference = collect(['laralum', 'dashboard', 'users', 'roles', 'permissions']);

        $ordered_widgets = [];
        $final_ordered_widgets = [];

        $widgets = collect($widgets)->groupBy('package')->toArray();

        foreach (Packages::all() as $package) {
            if (!in_array($package, $preference->toArray())) {
                $preference->push($package);
            }
        }

        $ordered_widgets = $preference->map(function ($p) use ($widgets) {
            return array_key_exists($p, $widgets) ? $widgets[$p] : null;
        })->filter();

        foreach ($ordered_widgets as $widget) {
            foreach ($widget as $w) {
                array_push($final_ordered_widgets, $w);
            }
        }

        return $final_ordered_widgets;
    }