@@ -704,61 +704,49 @@ You can add widgets to the admin dashboard to display important information, sta
704704
705705### Creating a Custom Widget
706706
707- 1 . Generate a new widget class:
707+ 1 . Generate a new widget class to your panel provider :
708708
709709``` bash
710- php artisan make:filament-widget StatsOverview
710+ php artisan make:filament-widget StatsOverview --panel=cms
711711```
712712
713- 2 . Register your widget:
713+ 2 . Then, you can optionally register your widget to dashboard page :
714714
715715You can register your custom widgets in two ways:
716716
717- ** Option 1: Using configuration **
717+ ** Option 1: Register on service provider **
718718
719- ``` php
719+ ``` php{title="app/Providers/AppServiceProvider.php"}
720720<?php
721721
722722namespace App\Providers;
723723
724- use App\Filament\Widgets\StatsOverview;
724+ use App\Filament\Cms\ Widgets\StatsOverview;
725725use Illuminate\Support\ServiceProvider;
726726use SolutionForest\InspireCms\InspireCmsConfig;
727727
728728class AppServiceProvider extends ServiceProvider
729729{
730730 public function register()
731731 {
732- // Register your custom widget
732+ // Register your custom widget to CMS Dashboard
733733 InspireCmsConfig::set('admin.extra_widgets.stats_overview', StatsOverview::class);
734734 }
735735}
736736```
737737
738- ** Option 2: Using a custom panel provider**
739-
740- ``` php
741- <?php
742-
743- namespace App\Providers;
744-
745- use App\Filament\Widgets\StatsOverview;
746- use Filament\Panel;
747- use SolutionForest\InspireCms\CmsPanelProvider;
748-
749- class MyCmsPanelProvider extends CmsPanelProvider
750- {
751- protected function configureCmsPanel(Panel $panel): Panel
752- {
753- $panel = parent::configureCmsPanel($panel);
754-
755- return $panel
756- ->widgets([
757- StatsOverview::class,
758- // Add more widgets here
759- ]);
760- }
761- }
738+ ** Option 2: Using configuration**
739+
740+ ``` php{title="config/inspirecms.php"}
741+ //...
742+ 'admin' => [
743+ // ...
744+ 'extra_widgets' => [
745+ // Extra widgets to be added to the CMS Dashboard
746+ \App\Filament\Cms\Widgets\Test::class,
747+ ],
748+ //..
749+ ],
762750```
763751
764752### Example Widget Class
0 commit comments