@@ -12,46 +12,25 @@ class LeadingTeacherExpertiseSeeder extends Seeder
1212 */
1313 public function run (): void
1414 {
15- create (LeadingTeacherExpertise::class, [
16- 'id ' => 1 ,
17- 'position ' => 10 ,
18- 'name ' => 'Teacher Trainer ' ,
19- ]);
20- create (LeadingTeacherExpertise::class, [
21- 'id ' => 2 ,
22- 'position ' => 20 ,
23- 'name ' => 'Community Organiser ' ,
24- ]);
25- create (LeadingTeacherExpertise::class, [
26- 'id ' => 3 ,
27- 'position ' => 30 ,
28- 'name ' => 'Expert in unplugged programming ' ,
29- ]);
30- create (LeadingTeacherExpertise::class, [
31- 'id ' => 4 ,
32- 'position ' => 40 ,
33- 'name ' => 'Expert in Scratch ' ,
34- ]);
35- create (LeadingTeacherExpertise::class, [
36- 'id ' => 5 ,
37- 'position ' => 50 ,
38- 'name ' => 'Expert in Robotics ' ,
39- ]);
40- create (LeadingTeacherExpertise::class, [
41- 'id ' => 6 ,
42- 'position ' => 60 ,
43- 'name ' => 'Expert in programming (Python, C++, SQL, etc.) ' ,
44- ]);
45- create (LeadingTeacherExpertise::class, [
46- 'id ' => 7 ,
47- 'position ' => 70 ,
48- 'name ' => 'Expert in remote/hybrid teaching ' ,
49- ]);
50- create (LeadingTeacherExpertise::class, [
51- 'id ' => 8 ,
52- 'position ' => 80 ,
53- 'name ' => 'Expert in use of remote teaching platforms ' ,
54- ]);
15+ // Ensure data is seeded only if it doesn't already exist
16+ $ expertises = [
17+ ['position ' => 10 , 'name ' => 'Teacher Trainer ' ],
18+ ['position ' => 20 , 'name ' => 'Community Organiser ' ],
19+ ['position ' => 30 , 'name ' => 'Expert in unplugged programming ' ],
20+ ['position ' => 40 , 'name ' => 'Expert in Scratch ' ],
21+ ['position ' => 50 , 'name ' => 'Expert in Robotics ' ],
22+ ['position ' => 60 , 'name ' => 'Expert in programming (Python, C++, SQL, etc.) ' ],
23+ ['position ' => 70 , 'name ' => 'Expert in remote/hybrid teaching ' ],
24+ ['position ' => 80 , 'name ' => 'Expert in use of remote teaching platforms ' ],
25+ ];
5526
27+ foreach ($ expertises as $ expertise ) {
28+ LeadingTeacherExpertise::updateOrCreate (
29+ ['name ' => $ expertise ['name ' ]], // Check for existing entry by name
30+ ['position ' => $ expertise ['position ' ]]
31+ );
32+ }
33+
34+ $ this ->command ->info ("✅ Leading teacher expertises seeded successfully! " );
5635 }
5736}
0 commit comments