pingcrm/database/seeders/DatabaseSeeder.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2019-03-05 18:10:11 -03:00
<?php
namespace Database\Seeders;
2020-09-08 19:45:49 -03:00
use App\Models\Account;
use App\Models\Contact;
use App\Models\Organization;
use App\Models\User;
2019-03-05 18:10:11 -03:00
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
2019-03-05 18:10:11 -03:00
public function run()
{
2019-03-18 08:53:00 -03:00
$account = Account::create(['name' => 'Acme Corporation']);
User::factory()->create([
2019-03-18 08:53:00 -03:00
'account_id' => $account->id,
2019-04-01 13:15:14 -03:00
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'johndoe@example.com',
2021-12-08 13:59:08 -03:00
'password' => 'secret',
2019-03-18 08:53:00 -03:00
'owner' => true,
]);
User::factory(5)->create(['account_id' => $account->id]);
2019-03-18 08:53:00 -03:00
$organizations = Organization::factory(100)
2019-03-18 08:53:00 -03:00
->create(['account_id' => $account->id]);
Contact::factory(100)
2019-03-18 08:53:00 -03:00
->create(['account_id' => $account->id])
->each(function ($contact) use ($organizations) {
$contact->update(['organization_id' => $organizations->random()->id]);
});
2019-03-05 18:10:11 -03:00
}
}