database/seeds/LikeSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        $posts = User::all()->toArray();
        foreach ( $posts as $post ){
            $user = User::all()->random()->id;
            Like::create([
                'user_id' => $user,
                'post_id' => $post['id']
            ]);
        }
    }
public function run ( ) { $ posts = User :: all ( ) -> toArray ( ) ; foreach ( $ posts as $ post ) { $ user = User :: all ( ) -> random ( ) -> id ; Like :: create ( [ 'user_id' => $ user , 'post_id' => $ post [ 'id' ] ] ) ; } }
Run the database seeds.
Run the database seeds .