database/seeds/TopicTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
      $faker = Faker::create();
      $courses = Course::all()->pluck('id')->toArray();
        foreach (range(1,40) as $index) {
            DB::table('topic')->insert([
              'course_id' => $faker->randomElement($courses),
              'topic' => $faker->word,
              'descriptions' => $faker->paragraph,
              'start_date' => $faker->date('Y-m-d', now()),
              'end_date' => $faker->date('Y-m-d', strtotime('+1 Days')),
              'created_at'  =>  now(),
              'updated_at'  =>  now()
            ]);
          }
    }
public function run ( ) { $ faker = Faker :: create ( ) ; $ courses = Course :: all ( ) -> pluck ( 'id' ) -> toArray ( ) ; foreach ( range ( 1 , 40 ) as $ index ) { DB :: table ( 'topic' ) -> insert ( [ 'course_id' => $ faker -> randomElement ( $ courses ) , 'topic' => $ faker -> word , 'descriptions' => $ faker -> paragraph , 'start_date' => $ faker -> date ( 'Y-m-d' , now ( ) ) , 'end_date' => $ faker -> date ( 'Y-m-d' , strtotime ( '+1 Days' ) ) , 'created_at' => now ( ) , 'updated_at' => now ( ) ] ) ; } }
Run the database seeds.
Run the database seeds .