Files
fotospiel-app/database/seeders/TasksSeeder.php

63 lines
2.5 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\{Emotion, Task, EventType};
class TasksSeeder extends Seeder
{
public function run(): void
{
// Create or get demo tenant
$demoTenant = \App\Models\Tenant::updateOrCreate(
['slug' => 'demo'],
[
'name' => 'Demo Tenant',
'domain' => null,
'is_active' => true,
'is_suspended' => false,
'settings' => json_encode([]),
'settings_updated_at' => null,
]
);
$seed = [
'Liebe' => [
['title'=>['de'=>'Kuss-Foto','en'=>'Kiss Photo'], 'description'=>['de'=>'Macht ein romantisches Kuss-Foto','en'=>'Take a romantic kiss photo'], 'difficulty'=>'easy'],
],
'Freude' => [
['title'=>['de'=>'Sprung-Foto','en'=>'Jump Photo'], 'description'=>['de'=>'Alle springen gleichzeitig!','en'=>'Everyone jump together!'], 'difficulty'=>'medium'],
],
'Teamgeist' => [
['title'=>['de'=>'High-Five-Runde','en'=>'High-Five Round'], 'description'=>['de'=>'Gebt euch High-Fives!','en'=>'Give each other high-fives!'], 'difficulty'=>'easy', 'event_type'=>'corporate'],
],
'Besinnlichkeit' => [
['title'=>['de'=>'Lichterglanz','en'=>'Glow of Lights'], 'description'=>['de'=>'Foto mit Lichterkette','en'=>'Photo with string lights'], 'difficulty'=>'easy', 'event_type'=>'christmas'],
],
];
$types = EventType::pluck('id','slug');
foreach ($seed as $emotionNameDe => $tasks) {
$emotion = Emotion::where('name->de', $emotionNameDe)->first();
if (!$emotion) continue;
foreach ($tasks as $t) {
Task::updateOrCreate([
'emotion_id' => $emotion->id,
'title->de' => $t['title']['de'],
'tenant_id' => $demoTenant->id
], [
'tenant_id' => $demoTenant->id,
'emotion_id' => $emotion->id,
'event_type_id' => isset($t['event_type']) && isset($types[$t['event_type']]) ? $types[$t['event_type']] : null,
'title' => $t['title'],
'description' => $t['description'],
'difficulty' => $t['difficulty'],
'is_active' => true,
]);
}
}
}
}