Без опису

ProfessorSectionSeeder.php 426B

123456789101112131415161718192021
  1. <?php
  2. use Illuminate\Database\Seeder;
  3. use App\Professor;
  4. use App\Section;
  5. class ProfessorSectionSeeder extends Seeder
  6. {
  7. /**
  8. * Run the database seeds.
  9. *
  10. * @return void
  11. */
  12. public function run()
  13. {
  14. Professor::all()->each(function ($professor) {
  15. $sections = Section::inRandomOrder()->take(3)->get();
  16. $professor->sections()->saveMany($sections);
  17. });
  18. }
  19. }