/** * Handle loading the dashboard widgets. * * @param DashboardBuilder $builder * @return array */ public function handle(DashboardBuilder $builder) { $module = $this->modules->active(); $builder->setWidgets(array_map(function (Extension $widget) { return $widget->getProvides(); }, $this->extensions->search($module->getNamespace('widget.*'))->all())); }
/** * Normalize widget input. * * @param DashboardBuilder $builder */ public function normalize(DashboardBuilder $builder) { $widgets = $builder->getWidgets(); foreach ($widgets as &$widget) { /** * If the widget is a a string and there is no slug * then use the widget as the widget parameter. */ if (is_string($widget)) { $widget = compact('widget'); } } $builder->setWidgets($widgets); }