You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
topnotch_website/database/seeders/ProductServiceSeeder.php

25 lines
557 B
PHP

<?php
namespace Database\Seeders;
use App\Models\Order;
use App\Models\ProductService;
use App\Models\ServiceType;
use Illuminate\Database\Seeder;
class ProductServiceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
foreach (Order::all() as $order) {
ProductService::factory(rand(1, 4), [
'order_id' => $order->id,
'service_type_id' => ServiceType::find(rand(1, count(ServiceType::all()))),
])->create();
}
}
}