<?php

namespace Database\Seeders;

use App\Models\ProductManagement\Product;
use App\Models\ProductManagement\Tag;
use Illuminate\Database\Seeder;

class ProductTagTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $products = Product::all();

        foreach ($products as $product) {
            $tags = Tag::inRandomOrder()->take(2)->pluck('id')->toArray();
            $product->tags()->sync($tags);
        }
    }
}
