34 lines
899 B
PHP
34 lines
899 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Services\LemonSqueezy\LemonSqueezyGiftVoucherCatalogService;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class GiftVoucherTierSeeder extends Seeder
|
|
{
|
|
public function __construct(private readonly LemonSqueezyGiftVoucherCatalogService $catalog) {}
|
|
|
|
public function run(): void
|
|
{
|
|
if (! config('lemonsqueezy.api_key')) {
|
|
$this->command?->warn('Skipping gift voucher Lemon Squeezy sync: lemonsqueezy.api_key not configured.');
|
|
|
|
return;
|
|
}
|
|
|
|
$tiers = config('gift-vouchers.tiers', []);
|
|
|
|
foreach ($tiers as $tier) {
|
|
$result = $this->catalog->ensureTier($tier);
|
|
|
|
$this->command?->info(sprintf(
|
|
'%s → product %s, variant %s',
|
|
$tier['key'],
|
|
$result['product_id'],
|
|
$result['variant_id']
|
|
));
|
|
}
|
|
}
|
|
}
|