42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Brand;
|
|
use App\Models\Customer;
|
|
use App\Models\CustomerInfo;
|
|
use App\Models\CustomerLogin;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class CustomerSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
Customer::factory(10)->create()->each(
|
|
function ($customer) {
|
|
/** @var \App\Models\Brand */
|
|
foreach (Brand::all() as $brand) {
|
|
CustomerInfo::factory(1)->make()->each(
|
|
function ($customerInfo) use ($customer, $brand) {
|
|
$customerInfo->customer()->associate($customer);
|
|
$customerInfo->brand()->associate($brand);
|
|
$customerInfo->save();
|
|
}
|
|
);
|
|
CustomerLogin::factory(1)->make()->each(
|
|
function ($customerLogin) use ($customer, $brand) {
|
|
$customerLogin->customer()->associate($customer);
|
|
$customerLogin->brand()->associate($brand);
|
|
$customerLogin->save();
|
|
}
|
|
);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|