Files
fotospiel-app/database/seeders/EmotionsSeeder.php
2025-09-08 14:03:43 +02:00

45 lines
2.4 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Emotion;
use App\Models\EventType;
use Illuminate\Support\Facades\DB;
class EmotionsSeeder extends Seeder
{
public function run(): void
{
$emotionData = [
['name'=>['de'=>'Liebe','en'=>'Love'], 'icon'=>'💖', 'color'=>'#ff6b9d', 'description'=>['de'=>'Romantische Momente','en'=>'Romantic moments'], 'sort_order'=>1],
['name'=>['de'=>'Freude','en'=>'Joy'], 'icon'=>'😊', 'color'=>'#ffd93d', 'description'=>['de'=>'Fröhliche Augenblicke','en'=>'Happy moments'], 'sort_order'=>2],
['name'=>['de'=>'Rührung','en'=>'Touched'], 'icon'=>'🥹', 'color'=>'#6bcf7f', 'description'=>['de'=>'Berührende Szenen','en'=>'Touching scenes'], 'sort_order'=>3],
['name'=>['de'=>'Nostalgie','en'=>'Nostalgia'], 'icon'=>'🕰️', 'color'=>'#a78bfa', 'description'=>['de'=>'Erinnerungen','en'=>'Memories'], 'sort_order'=>4],
['name'=>['de'=>'Überraschung','en'=>'Surprise'], 'icon'=>'😲', 'color'=>'#fb7185', 'description'=>['de'=>'Unerwartete Momente','en'=>'Unexpected moments'], 'sort_order'=>5],
['name'=>['de'=>'Stolz','en'=>'Pride'], 'icon'=>'🏆', 'color'=>'#34d399', 'description'=>['de'=>'Triumphale Augenblicke','en'=>'Triumphal moments'], 'sort_order'=>6],
['name'=>['de'=>'Teamgeist','en'=>'Team Spirit'], 'icon'=>'🤝', 'color'=>'#38bdf8', 'description'=>['de'=>'Zusammenhalt','en'=>'Team bonding'], 'sort_order'=>7],
['name'=>['de'=>'Besinnlichkeit','en'=>'Contemplation'], 'icon'=>'🕯️', 'color'=>'#22c55e', 'description'=>['de'=>'Feierliche Stimmung','en'=>'Festive calm'], 'sort_order'=>8],
];
$typeIds = EventType::pluck('id','slug');
foreach ($emotionData as $e) {
$emotion = Emotion::updateOrCreate(['name->de' => $e['name']['de']], $e);
// Link to types
$links = ['wedding','birthday','corporate','christmas'];
if ($e['name']['de'] === 'Teamgeist') { $links = ['corporate']; }
if ($e['name']['de'] === 'Besinnlichkeit') { $links = ['christmas']; }
foreach ($links as $slug) {
if (isset($typeIds[$slug])) {
DB::table('emotion_event_type')->updateOrInsert([
'emotion_id' => $emotion->id,
'event_type_id' => $typeIds[$slug],
], []);
}
}
}
}
}