boot
function.add_filter(DASHBOARD_FILTER_ADMIN_LIST, [$this, 'registerDashboardWidgets'], 1221, 2);
1221
is the priority, it can be any number but must unique.
public function registerDashboardWidgets($widgets, $widgetSettings)
{
$widget = new DashboardWidgetInstance;
$widget->permission = 'the permission key to check';
$widget->key = 'widget_your_widget_key';
$widget->title = __('Widget name');
$widget->icon = 'fas fa-history';
$widget->color = '#44b6ae';
$widget->route = route('the-route-to-get-data');
$widget->bodyClass = 'scroll-table';
$widget->column = 'col-md-6 col-sm-6';
return $widget->init($widgets, $widgetSettings);
}
the-route-to-get-data
).public function getDataForWidget(Request $request, BaseHttpResponse $response)
{
$content = 'The content can be a string or rendered from a blade view';
// $content = view('plugins.your-plugin::widgets.sample', compact('data'))->render()
return $response
->setError(false)
->setData($content);
}