database/seeds/AssignmentTableSeeder.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();
        $teacher = User::all()->where('type','=',2)->pluck('id')->toArray();
        foreach (range(1,20) as $index) {
            DB::table('assignment')->insert([
              'name'         => $faker->word,
              'teacher_id'   => $faker->randomElement($teacher),
              'created_at'   => now(),
              'updated_at'   => now()
            ]);
          }
    }
public function run ( ) { $ faker = Faker :: create ( ) ; $ teacher = User :: all ( ) -> where ( 'type' , '=' , 2 ) -> pluck ( 'id' ) -> toArray ( ) ; foreach ( range ( 1 , 20 ) as $ index ) { DB :: table ( 'assignment' ) -> insert ( [ 'name' => $ faker -> word , 'teacher_id' => $ faker -> randomElement ( $ teacher ) , 'created_at' => now ( ) , 'updated_at' => now ( ) ] ) ; } }
Run the database seeds.
Run the database seeds .