25 lines
490 B
PHP
25 lines
490 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Product;
|
|
use App\Models\Range;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class ProductSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$ranges = Range::all();
|
|
|
|
Product::factory(150)->make()->each(function (Product $product) use ($ranges) {
|
|
$product->range()->associate($ranges->random());
|
|
$product->save();
|
|
});
|
|
}
|
|
}
|