File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public function handle(): int
44
44
File::ensureDirectoryExists (resource_path ('views/components/layouts ' ));
45
45
File::put (resource_path ('views/components/layouts/app.blade.php ' ), File::get (__DIR__ .'/../../stubs/app.blade.php.stub ' ));
46
46
File::put (resource_path ('views/welcome.blade.php ' ), File::get (__DIR__ .'/../../stubs/welcome.blade.php.stub ' ));
47
+ File::ensureDirectoryExists (resource_path ('views/components/svg ' ));
47
48
File::put (resource_path ('views/components/svg/logo.blade.php ' ), File::get (__DIR__ .'/../../stubs/logo.blade.php.stub ' ));
48
49
return self ::SUCCESS ;
49
50
}
Original file line number Diff line number Diff line change 4
4
5
5
use ArtisanBuild \Till \Attributes \IndividualPlan ;
6
6
use ArtisanBuild \Till \Attributes \TeamPlan ;
7
+ use ArtisanBuild \Till \Contracts \PlanInterface ;
8
+ use ArtisanBuild \Till \Enums \PlanTerms ;
9
+ use ArtisanBuild \Till \SubscriptionPlans \BasePlan ;
7
10
use Illuminate \Support \Collection ;
8
11
use Illuminate \Support \Facades \File ;
9
12
use Illuminate \Support \Str ;
10
13
use ReflectionClass ;
14
+ use Stripe \Plan ;
11
15
12
16
class GetPlans
13
17
{
@@ -35,12 +39,18 @@ public function __invoke(): Collection
35
39
return null ;
36
40
})
37
41
->filter () // Remove null values (files without classes)
38
- ->map (fn ($ class ) => new $ class )->filter (function ($ plan ) {
42
+ ->filter (fn ($ class ) => new $ class )->filter (function ($ plan ) {
39
43
$ attribute = config ('till.team_mode ' ) ? TeamPlan::class : IndividualPlan::class;
40
44
41
45
$ reflection = new ReflectionClass ($ plan );
42
46
43
47
return ! empty ($ reflection ->getAttributes ($ attribute ));
44
- })->sortBy (['prices.month.price ' , 'price.year.price ' , 'price.life.price ' ]);
48
+ })
49
+ ->map (fn (string $ plan ): BasePlan => new $ plan )
50
+ ->sort (function (BasePlan $ plan_a , BasePlan $ plan_b ) {
51
+ $ a = $ plan_a ->prices [PlanTerms::Life->value ] ?? $ plan_a ->prices [PlanTerms::Year->value ] ?? $ plan_a ->prices [PlanTerms::Month->value ] ?? $ plan_a ->prices [PlanTerms::Week->value ];
52
+ $ b = $ plan_b ->prices [PlanTerms::Life->value ] ?? $ plan_b ->prices [PlanTerms::Year->value ] ?? $ plan_b ->prices [PlanTerms::Month->value ] ?? $ plan_b ->prices [PlanTerms::Week->value ];
53
+ return $ a <=> $ b ;
54
+ });
45
55
}
46
56
}
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class BasePlan implements PlanInterface
11
11
{
12
12
public string $ id ;
13
13
14
+ public array $ prices = [];
15
+
14
16
public bool $ current = false ;
15
17
16
18
public $ currency = Currencies::USD ;
You can’t perform that action at this time.
0 commit comments