115 lines
4.2 KiB
PHP
115 lines
4.2 KiB
PHP
<?php
|
||
|
||
namespace Database\Seeders;
|
||
|
||
use App\Models\OfferItem;
|
||
use App\Models\OfferTemplate;
|
||
use App\User;
|
||
use Illuminate\Database\Seeder;
|
||
|
||
/**
|
||
* Legt 5 Angebots-Vorlagen für manuelle/QA-Tests an.
|
||
*
|
||
* Ausführung: `php artisan db:seed --class=Database\\Seeders\\OfferTemplateSeeder`
|
||
* (benötigt mindestens einen User in `users` und ausgeführte Offer-Migrationen).
|
||
*/
|
||
class OfferTemplateSeeder extends Seeder
|
||
{
|
||
public function run(): void
|
||
{
|
||
$userId = User::query()->orderBy('id')->value('id');
|
||
if (! $userId) {
|
||
$this->command?->warn('OfferTemplateSeeder: kein User — übersprungen.');
|
||
|
||
return;
|
||
}
|
||
|
||
$templates = [
|
||
[
|
||
'name' => 'Südafrika – Klassik (14 Tage)',
|
||
'description' => 'Kombirundreise, Baustein für B2-Modal-Tests',
|
||
'default_headline' => 'Ihr Südafrika-Erlebnis',
|
||
'default_intro' => '<p>Sehr geehrte Gäste, wir freuen uns, Ihnen folgendes Reiseangebot zu unterbreiten.</p>',
|
||
'default_items' => [
|
||
[
|
||
'type' => OfferItem::TYPE_TRAVEL,
|
||
'title' => 'Rundreise 14 Tage inkl. Mietwagen',
|
||
'quantity' => 2,
|
||
'price_per_unit' => 1_800.00,
|
||
],
|
||
[
|
||
'type' => OfferItem::TYPE_OPTION,
|
||
'title' => 'Business-Class-Aufpreis (Flug)',
|
||
'quantity' => 2,
|
||
'price_per_unit' => 450.00,
|
||
],
|
||
],
|
||
],
|
||
[
|
||
'name' => 'Namibia – Self-Drive',
|
||
'default_headline' => 'Namibia per Mietwagen',
|
||
'default_items' => [
|
||
[
|
||
'type' => OfferItem::TYPE_TRAVEL,
|
||
'title' => 'Mietwagen 10 Tage',
|
||
'quantity' => 1,
|
||
'price_per_unit' => 890.00,
|
||
],
|
||
],
|
||
],
|
||
[
|
||
'name' => 'Mauritius – Strand (8 Nächte)',
|
||
'default_headline' => 'Honeymoon-Insel',
|
||
'default_items' => [
|
||
[
|
||
'type' => OfferItem::TYPE_TRAVEL,
|
||
'title' => 'Hotel 5* Halbpension (p.P.)',
|
||
'quantity' => 2,
|
||
'price_per_unit' => 1_200.00,
|
||
],
|
||
],
|
||
],
|
||
[
|
||
'name' => 'Kurzangebot – Städtereise',
|
||
'default_headline' => 'Wochenend-Trip',
|
||
'default_items' => [
|
||
[
|
||
'type' => OfferItem::TYPE_SERVICE,
|
||
'title' => 'Transfer Flughafen',
|
||
'quantity' => 1,
|
||
'price_per_unit' => 75.00,
|
||
],
|
||
],
|
||
],
|
||
[
|
||
'name' => 'Rabatt-Template (Frühbucher)',
|
||
'default_headline' => 'Frühbucher-Sonderkonditionen',
|
||
'default_items' => [
|
||
[
|
||
'type' => OfferItem::TYPE_TRAVEL,
|
||
'title' => 'Basispaket',
|
||
'quantity' => 2,
|
||
'price_per_unit' => 1_000.00,
|
||
],
|
||
[
|
||
'type' => OfferItem::TYPE_DISCOUNT,
|
||
'title' => 'Frühbucher-Rabatt',
|
||
'quantity' => 1,
|
||
'price_per_unit' => -200.00,
|
||
],
|
||
],
|
||
],
|
||
];
|
||
|
||
foreach ($templates as $t) {
|
||
OfferTemplate::query()->updateOrCreate(
|
||
['name' => $t['name']],
|
||
array_merge($t, [
|
||
'branch_id' => null,
|
||
'is_active' => true,
|
||
'created_by' => $userId,
|
||
])
|
||
);
|
||
}
|
||
}
|
||
}
|