Initialize repo and add session changes (2025-09-08)
This commit is contained in:
48
database/seeders/TasksSeeder.php
Normal file
48
database/seeders/TasksSeeder.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\{Emotion, Task, EventType};
|
||||
|
||||
class TasksSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$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']
|
||||
], [
|
||||
'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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user