|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace Database\Seeders;
|
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Category;
|
|
|
|
use App\Models\Product;
|
|
|
|
use App\Models\Product;
|
|
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
@ -15,5 +16,10 @@ class ProductSeeder extends Seeder
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//
|
|
|
|
//
|
|
|
|
Product::factory()->count(31)->create();
|
|
|
|
Product::factory()->count(31)->create();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Product::all() as $product) {
|
|
|
|
|
|
|
|
$product->categories()->sync(Category::inRandomOrder()->limit(3)->pluck('id')->toArray());
|
|
|
|
|
|
|
|
$product->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|