presseportale/database/seeders/PaymentOptionSeeder.php
Kevin Adametz 17eaa80135 R0.4: Seeder produktionssicher (PlanSeeder, keine Fake-Stripe-IDs, Dev-User-Guard)
- PlanSeeder (Starter/Business/Pro/Agency) haengt jetzt im DatabaseSeeder
- PaymentOptionSeeder erfindet keine prod_/price_placeholder-IDs mehr
  (Spalten nullable; echte Verknuepfung via Stripe-Sync/Pflege)
- Demo-Zugaenge admin@pressekonto.test/test@example.com (Passwort
  "password") werden nur noch in local/testing angelegt

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 07:58:30 +00:00

78 lines
2.8 KiB
PHP

<?php
namespace Database\Seeders;
use App\Enums\PaymentOptionType;
use App\Models\PaymentOption;
use Illuminate\Database\Seeder;
class PaymentOptionSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$options = [
[
'article_number' => 'PR-MONTHLY-001',
'type' => PaymentOptionType::Recurring->value,
'price_cents' => 4900,
'currency' => 'EUR',
'interval' => 'monthly',
'is_hidden' => false,
'stripe_product_id' => null,
'stripe_price_id' => null,
'translations' => [
'de' => ['name' => 'Monatspaket', 'description' => 'Monatliche Veroeffentlichungen'],
'en' => ['name' => 'Monthly package', 'description' => 'Monthly publication package'],
],
],
[
'article_number' => 'PR-YEARLY-001',
'type' => PaymentOptionType::Recurring->value,
'price_cents' => 49900,
'currency' => 'EUR',
'interval' => 'yearly',
'is_hidden' => false,
'stripe_product_id' => null,
'stripe_price_id' => null,
'translations' => [
'de' => ['name' => 'Jahrespaket', 'description' => 'Jaehrliche Veroeffentlichungen'],
'en' => ['name' => 'Yearly package', 'description' => 'Yearly publication package'],
],
],
[
'article_number' => 'PR-BOOST-ONCE-001',
'type' => PaymentOptionType::Onetime->value,
'price_cents' => 9900,
'currency' => 'EUR',
'interval' => 'once',
'is_hidden' => false,
'stripe_product_id' => null,
'stripe_price_id' => null,
'translations' => [
'de' => ['name' => 'Reichweiten-Boost', 'description' => 'Einmaliger Promotion-Boost'],
'en' => ['name' => 'Reach boost', 'description' => 'One-time promotion boost'],
],
],
];
foreach ($options as $optionData) {
$translations = $optionData['translations'];
unset($optionData['translations']);
$option = PaymentOption::updateOrCreate(
['article_number' => $optionData['article_number']],
$optionData
);
foreach ($translations as $locale => $translation) {
$option->translations()->updateOrCreate(
['locale' => $locale],
$translation
);
}
}
}
}