generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dynamic allow promotion codes based on configuration
- Loading branch information
1 parent
43810b5
commit 62205fb
Showing
3 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maartenpaauw\Filament\Cashier; | ||
|
||
use Illuminate\Config\Repository; | ||
use InvalidArgumentException; | ||
|
||
final class Plan | ||
{ | ||
public function __construct( | ||
private readonly Repository $repository, | ||
private readonly string $type = 'default', | ||
) { | ||
} | ||
|
||
public function type(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function priceId(): string | ||
{ | ||
return $this->repository->get( | ||
"cashier.plans.$this->type.price_id", | ||
static fn (): never => throw new InvalidArgumentException('Invalid plan configuration'), | ||
); | ||
} | ||
|
||
public function trialDays(): int | false | ||
{ | ||
return $this->repository->get("cashier.plans.$this->type.trial_days", false); | ||
} | ||
|
||
public function allowPromotionCodes(): bool | ||
{ | ||
return $this->repository->get("cashier.plans.$this->type.allow_promotion_codes", false); | ||
} | ||
|
||
public function collectTaxIds(): bool | ||
{ | ||
return $this->repository->get("cashier.plans.$this->type.collect_tax_ids", false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters