File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ The package auto-registers its service provider via the `extra.laravel.providers
3232### Migrations
3333This package discovers and loads its migrations. Run your app migrations after installing:
3434
35+ ``` bash
36+ php artisan vendor:publish --tag=" filament-webhooks-migrations"
37+ ```
38+
3539``` bash
3640php artisan migrate
3741```
Original file line number Diff line number Diff line change 1515
1616 'model ' => InboundWebhook::class,
1717 'providers_enum ' => InboundWebhookSource::class,
18+ 'view_any ' => true ,
1819];
Original file line number Diff line number Diff line change 77use BackedEnum ;
88use Basement \Webhooks \Filament \Admin \Resources \InboundWebhook \Pages \ListInboundWebhooks ;
99use Basement \Webhooks \Filament \Admin \Resources \InboundWebhook \Pages \ViewInboundWebhook ;
10+ use Basement \Webhooks \Filament \Admin \Widgets \InboundWebhookStatsBySource ;
1011use Basement \Webhooks \Models \InboundWebhook ;
1112use Filament \Resources \Resource ;
1213use Filament \Support \Icons \Heroicon ;
@@ -76,4 +77,16 @@ public static function getGloballySearchableAttributes(): array
7677 {
7778 return [];
7879 }
80+
81+ public static function getWidgets (): array
82+ {
83+ return [
84+ InboundWebhookStatsBySource::make (),
85+ ];
86+ }
87+
88+ public static function canViewAny (): bool
89+ {
90+ return config ('filament-webhooks.view_any ' , true );
91+ }
7992}
Original file line number Diff line number Diff line change 55namespace Basement \Webhooks \Filament \Admin \Resources \InboundWebhook \Pages ;
66
77use Basement \Webhooks \Filament \Admin \Resources \InboundWebhook \InboundWebhookResource ;
8- use Basement \Webhooks \Filament \Admin \Widgets \InboundWebhookStatsByProviderPercentage ;
98use Basement \Webhooks \Filament \Admin \Widgets \InboundWebhookStatsBySource ;
109use Filament \Actions \BulkActionGroup ;
1110use Filament \Actions \DeleteAction ;
@@ -22,13 +21,6 @@ final class ListInboundWebhooks extends ListRecords
2221{
2322 protected static string $ resource = InboundWebhookResource::class;
2423
25- protected function getHeaderWidgets (): array
26- {
27- return [
28- InboundWebhookStatsBySource::make (),
29- ];
30- }
31-
3224 public function table (Table $ table ): Table
3325 {
3426 return $ table
@@ -54,4 +46,11 @@ public function table(Table $table): Table
5446 ]),
5547 ]);
5648 }
49+
50+ protected function getHeaderWidgets (): array
51+ {
52+ return [
53+ InboundWebhookStatsBySource::make (),
54+ ];
55+ }
5756}
Original file line number Diff line number Diff line change 11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Basement \Webhooks \Filament \Admin \Widgets ;
46
57use Basement \Webhooks \Enums \InboundWebhookSource ;
68use Basement \Webhooks \Models \InboundWebhook ;
79use Filament \Widgets \StatsOverviewWidget ;
810use Filament \Widgets \StatsOverviewWidget \Stat ;
911
10- class InboundWebhookStatsBySource extends StatsOverviewWidget
12+ final class InboundWebhookStatsBySource extends StatsOverviewWidget
1113{
1214 protected function getStats (): array
1315 {
@@ -22,11 +24,12 @@ private function getInboundWebhooksStats(): array
2224 foreach (InboundWebhookSource::cases () as $ source ) {
2325 $ count = InboundWebhook::where ('source ' , $ source ->value )->count ();
2426 $ percentage = $ totalWebhooks > 0 ? round (($ count / $ totalWebhooks ) * 100 , 2 ) : 0 ;
25- $ stats [] = Stat::make ("{$ source ->name }" ,"{$ percentage }% " )
27+ $ stats [] = Stat::make ("{$ source ->name }" , "{$ percentage }% " )
2628 ->descriptionIcon ($ source ->getIcon ())
2729 ->description ("{$ count } de {$ totalWebhooks } webhooks " )
2830 ->color ($ source ->getColor ());
2931 }
32+
3033 return $ stats ;
3134 }
3235}
Original file line number Diff line number Diff line change 55namespace Basement \Webhooks ;
66
77use Basement \Webhooks \Filament \Admin \Resources \InboundWebhook \InboundWebhookResource ;
8- use Basement \Webhooks \Filament \Admin \Widgets \InboundWebhookStatsByProviderPercentage ;
9- use Basement \Webhooks \Filament \Admin \Widgets \InboundWebhookStatsBySource ;
108use Filament \Contracts \Plugin ;
119use Filament \Panel ;
1210
@@ -27,9 +25,6 @@ public function register(Panel $panel): void
2725 $ panel ->resources ([
2826 InboundWebhookResource::class,
2927 ]);
30- $ panel ->widgets ([
31- InboundWebhookStatsBySource::make (),
32- ]);
3328 }
3429
3530 public function boot (Panel $ panel ): void {}
Original file line number Diff line number Diff line change 1010use Illuminate \Database \Eloquent \Model ;
1111use Illuminate \Database \Eloquent \SoftDeletes ;
1212
13-
1413final class InboundWebhook extends Model
1514{
1615 use HasFactory;
@@ -24,6 +23,11 @@ final class InboundWebhook extends Model
2423 'payload ' ,
2524 ];
2625
26+ protected static function newFactory (): InboundWebhookFactory
27+ {
28+ return InboundWebhookFactory::new ();
29+ }
30+
2731 protected function casts (): array
2832 {
2933 return [
@@ -32,9 +36,4 @@ protected function casts(): array
3236 'source ' => config ('filament-webhooks.providers_enum ' ),
3337 ];
3438 }
35-
36- protected static function newFactory (): InboundWebhookFactory
37- {
38- return InboundWebhookFactory::new ();
39- }
4039}
You can’t perform that action at this time.
0 commit comments