Açıklama Yok

ProfessorSemesterSeeder.php 432B

123456789101112131415161718192021
  1. <?php
  2. use Illuminate\Database\Seeder;
  3. use App\Professor;
  4. use App\Semester;
  5. class ProfessorSemesterSeeder 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. $semesters = Semester::inRandomOrder()->take(2)->get();
  16. $professor->semesters()->saveMany($semesters);
  17. });
  18. }
  19. }