database/seeds/LikeTableSeeder.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();
      $users = User::all()->pluck('id')->toArray();
      $activities = Activity::all()->pluck('id')->toArray();
        foreach (range(1,20) as $index) {
            DB::table('like')->insert([
              'user_id' => $faker->randomElement($users),
              'activity_id' =>$faker->randomElement($activities),
              'created_at'  =>  now(),
              'updated_at'  =>  now()
            ]);
          }
    }
public function run ( ) { $ faker = Faker :: create ( ) ; $ users = User :: all ( ) -> pluck ( 'id' ) -> toArray ( ) ; $ activities = Activity :: all ( ) -> pluck ( 'id' ) -> toArray ( ) ; foreach ( range ( 1 , 20 ) as $ index ) { DB :: table ( 'like' ) -> insert ( [ 'user_id' => $ faker -> randomElement ( $ users ) , 'activity_id' => $ faker -> randomElement ( $ activities ) , 'created_at' => now ( ) , 'updated_at' => now ( ) ] ) ; } }
Run the database seeds.
Run the database seeds .