ldc-crm/database/seeders/CustomerSeeder.php
Jérémy Munsch 6987501a98 CRM API V2
2021-03-27 08:29:31 +01:00

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();
}
);
}
}
);
}
}