Skip to content

Commit b7f9311

Browse files
authored
Merge pull request #17 from osenco/master
Update composer.json
2 parents ebaf979 + dbd5264 commit b7f9311

File tree

6 files changed

+54
-22
lines changed

6 files changed

+54
-22
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Users without an active subscription will be redirected to the billing page.
125125

126126
## Register New Subscriber Type
127127

128-
you can register new subscriber type by using this code
128+
You can register new subscriber type by using this code
129129

130130
```php
131131
use TomatoPHP\FilamentSubscriptions\Facades\FilamentSubscriptions;
@@ -140,6 +140,16 @@ public function boot()
140140
}
141141
```
142142

143+
## Use custom Billing page
144+
145+
You can create your own billing class and register it in `config/laravel-subscriptions.php`
146+
147+
```php
148+
'pages' => [
149+
'billing' => Billing::class,
150+
]
151+
```
152+
143153
## Use Events
144154

145155
we add events everywhere on the subscription process and here is the list of events

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"filament/spatie-laravel-media-library-plugin": "^3.0",
3838
"laravelcm/laravel-subscriptions": "^1.3",
3939
"tomatophp/console-helpers": "^1.1",
40-
"tomatophp/filament-locations": "^1.0",
40+
"tomatophp/filament-locations": "^2.0",
4141
"tomatophp/filament-translation-component": "^1.0"
4242
}
43-
}
43+
}

config/filament-subscriptions.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<?php
22

3+
use TomatoPHP\FilamentSubscriptions\Filament\Pages\Billing;
4+
5+
use TomatoPHP\FilamentSubscriptions\Filament\Resources\PlanResource;
6+
use TomatoPHP\FilamentSubscriptions\Filament\Resources\SubscriptionResource;
7+
38
return [
4-
"route" => "/admin/billing"
9+
"route" => "/admin/billing",
10+
11+
'pages' => [
12+
'billing' => Billing::class,
13+
],
14+
15+
'resources' => [
16+
'plan' => PlanResource::class,
17+
'subscription' => SubscriptionResource::class,
18+
],
519
];

src/Filament/Resources/PlanResource.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@
1818

1919
class PlanResource extends Resource
2020
{
21-
protected static ?string $model = Plan::class;
22-
2321
protected static ?string $navigationIcon = 'heroicon-o-bookmark';
2422

2523
protected static ?int $navigationSort = 1;
2624

25+
public static function getModel(): string
26+
{
27+
return config('laravel-subscriptions.models.plan', Plan::class);
28+
}
29+
2730
public static function getNavigationGroup(): ?string
2831
{
29-
return trans('filament-subscriptions::messages.group');
32+
return config('laravel-subscriptions.navigation.group', trans('filament-subscriptions::messages.group'));
3033
}
3134

3235
public static function getNavigationLabel(): string

src/Filament/Resources/SubscriptionResource.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121

2222
class SubscriptionResource extends Resource
2323
{
24-
protected static ?string $model = Subscription::class;
25-
2624
protected static ?string $navigationIcon = 'heroicon-o-credit-card';
2725

2826
protected static ?int $navigationSort = 2;
2927

28+
public static function getModel(): string
29+
{
30+
return config('laravel-subscriptions.models.subscription', Subscription::class);
31+
}
32+
3033
public static function getNavigationGroup(): ?string
3134
{
32-
return trans('filament-subscriptions::messages.group');
35+
return config('laravel-subscriptions.navigation.group', trans('filament-subscriptions::messages.group'));
3336
}
3437

3538
public static function getNavigationLabel(): string

src/FilamentSubscriptionsPlugin.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,50 @@ public function showUserMenu(bool $showUserMenu): static
2828
return $this;
2929
}
3030

31-
public function withoutResources(bool $withoutResources = true):static
31+
public function withoutResources(bool $withoutResources = true): static
3232
{
3333
$this->withoutResources = $withoutResources;
3434
return $this;
3535
}
3636

3737
public function register(Panel $panel): void
3838
{
39-
if(class_exists(Module::class) && \Nwidart\Modules\Facades\Module::find('FilamentSubscriptions')?->isEnabled()){
39+
if (class_exists(Module::class) && \Nwidart\Modules\Facades\Module::find('FilamentSubscriptions')?->isEnabled()) {
4040
$this->isActive = true;
41-
}
42-
else {
41+
} else {
4342
$this->isActive = true;
4443
}
4544

46-
if($this->isActive) {
45+
if ($this->isActive) {
4746
$panel
4847
->pages([
49-
Billing::class
48+
config('filament-subscriptions.pages.billing', Billing::class)
5049
]);
5150

5251
if (!$this->withoutResources) {
5352
$panel
5453
->resources([
55-
PlanResource::class,
56-
SubscriptionResource::class,
54+
config('filament-subscriptions.resources.plan', PlanResource::class),
55+
config('filament-subscriptions.resources.subscription', SubscriptionResource::class),
5756
]);
5857
}
5958
}
60-
61-
6259
}
6360

6461
public function boot(Panel $panel): void
6562
{
66-
if($this->isActive) {
63+
if ($this->isActive) {
6764
if ($this->showUserMenu && !filament()->hasTenancy()) {
6865
$panel->userMenuItems([
6966
MenuItem::make()
7067
->label(trans('filament-subscriptions::messages.menu'))
7168
->icon('heroicon-s-credit-card')
72-
->url(route('filament.' . $panel->getId() . '.tenant.billing'))
69+
->url(
70+
route(
71+
'filament.' . $panel->getId() . '.tenant.billing',
72+
// ['tenant'=> filament()->getTenant()->{filament()->getCurrentPanel()->getTenantSlugAttribute()}]
73+
)
74+
)
7375
]);
7476
}
7577
}

0 commit comments

Comments
 (0)