public function run() { $classeCN2 = Classe::where('code', '=', '420-CN2-DM')->first(); $classeDM1 = Classe::where('code', '=', '420-DM1-DM')->first(); $classeDM2 = Classe::where('code', '=', '420-DM2-DM')->first(); DB::table('classes_tps')->delete(); DB::table('tps')->delete(); $tp = new TP(); $tp->nom = 'TP1 CN2'; $tp->poids = 50; $tp->save(); $tp->classes()->attach($classeCN2->id, ['poids_local' => 50]); $tp = new TP(); $tp->nom = 'TP2 CN2'; $tp->poids = 50; $tp->save(); $tp->classes()->attach($classeCN2->id, ['poids_local' => 50]); $tp = new TP(); $tp->nom = 'TP1 DM1'; $tp->poids = 30; $tp->save(); $tp->classes()->attach($classeDM1->id, ['poids_local' => 50]); }