2019-03-05 18:10:11 -03:00
|
|
|
<?php
|
|
|
|
|
2019-03-18 08:53:00 -03:00
|
|
|
use App\User;
|
|
|
|
use App\Account;
|
|
|
|
use App\Contact;
|
|
|
|
use App\Organization;
|
2019-03-05 18:10:11 -03:00
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
|
|
{
|
|
|
|
public function run()
|
|
|
|
{
|
2019-03-18 08:53:00 -03:00
|
|
|
$account = Account::create(['name' => 'Acme Corporation']);
|
|
|
|
|
|
|
|
factory(User::class)->create([
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'first_name' => 'Jonathan',
|
|
|
|
'last_name' => 'Reinink',
|
|
|
|
'email' => 'jonathan@reinink.ca',
|
|
|
|
'owner' => true,
|
|
|
|
]);
|
|
|
|
|
|
|
|
factory(User::class, 5)->create(['account_id' => $account->id]);
|
|
|
|
|
|
|
|
$organizations = factory(Organization::class, 100)
|
|
|
|
->create(['account_id' => $account->id]);
|
|
|
|
|
|
|
|
factory(Contact::class, 100)
|
|
|
|
->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
|
|
|
}
|
|
|
|
}
|