File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace Boy132 \Billing \Filament \App \Widgets ;
44
5+ use App \Filament \Server \Pages \Console ;
56use Boy132 \Billing \Models \Customer ;
67use Boy132 \Billing \Models \Order ;
78use Boy132 \Billing \Models \Product ;
@@ -47,6 +48,13 @@ public function content(Schema $schema): Schema
4748 'product_price_id ' => $ price ->id ,
4849 ]);
4950
51+ if ($ price ->isFree ()) {
52+ $ order ->activate (null );
53+ $ order ->refresh ();
54+
55+ return redirect (Console::getUrl (panel: 'server ' , tenant: $ order ->server ));
56+ }
57+
5058 return $ this ->redirect ($ order ->getCheckoutSession ()->url );
5159 });
5260 }
Original file line number Diff line number Diff line change @@ -89,8 +89,17 @@ public function sync(): void
8989 }
9090 }
9191
92+ public function isFree (): bool
93+ {
94+ return !$ this ->cost ;
95+ }
96+
9297 public function formatCost (): string
9398 {
99+ if ($ this ->isFree ()) {
100+ return 'Free ' ;
101+ }
102+
94103 $ formatter = new NumberFormatter (user ()->language ?? 'en ' , NumberFormatter::CURRENCY );
95104
96105 return $ formatter ->formatCurrency ($ this ->cost , config ('billing.currency ' ));
You can’t perform that action at this time.
0 commit comments