Skip to content

Commit eb80e5d

Browse files
committed
Streaming
1 parent 2193199 commit eb80e5d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/flux-themes/src/Commands/InstallCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function handle(): int
4444
File::ensureDirectoryExists(resource_path('views/components/layouts'));
4545
File::put(resource_path('views/components/layouts/app.blade.php'), File::get(__DIR__.'/../../stubs/app.blade.php.stub'));
4646
File::put(resource_path('views/welcome.blade.php'), File::get(__DIR__.'/../../stubs/welcome.blade.php.stub'));
47+
File::ensureDirectoryExists(resource_path('views/components/svg'));
4748
File::put(resource_path('views/components/svg/logo.blade.php'), File::get(__DIR__.'/../../stubs/logo.blade.php.stub'));
4849
return self::SUCCESS;
4950
}

packages/till/src/Actions/GetPlans.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
use ArtisanBuild\Till\Attributes\IndividualPlan;
66
use ArtisanBuild\Till\Attributes\TeamPlan;
7+
use ArtisanBuild\Till\Contracts\PlanInterface;
8+
use ArtisanBuild\Till\Enums\PlanTerms;
9+
use ArtisanBuild\Till\SubscriptionPlans\BasePlan;
710
use Illuminate\Support\Collection;
811
use Illuminate\Support\Facades\File;
912
use Illuminate\Support\Str;
1013
use ReflectionClass;
14+
use Stripe\Plan;
1115

1216
class GetPlans
1317
{
@@ -35,12 +39,18 @@ public function __invoke(): Collection
3539
return null;
3640
})
3741
->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) {
3943
$attribute = config('till.team_mode') ? TeamPlan::class : IndividualPlan::class;
4044

4145
$reflection = new ReflectionClass($plan);
4246

4347
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+
});
4555
}
4656
}

packages/till/src/SubscriptionPlans/BasePlan.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class BasePlan implements PlanInterface
1111
{
1212
public string $id;
1313

14+
public array $prices = [];
15+
1416
public bool $current = false;
1517

1618
public $currency = Currencies::USD;

0 commit comments

Comments
 (0)