123456789101112131415161718192021 |
- <?php
-
- use Illuminate\Database\Seeder;
- use App\Professor;
- use App\Section;
-
- class ProfessorSectionSeeder extends Seeder
- {
- /**
- * Run the database seeds.
- *
- * @return void
- */
- public function run()
- {
- Professor::all()->each(function ($professor) {
- $sections = Section::inRandomOrder()->take(3)->get();
- $professor->sections()->saveMany($sections);
- });
- }
- }
|