faker = \Faker\Factory::create(); $this->account = Account::factory()->create(); $this->user = User::factory()->create([ 'account_id' => $this->account->id, 'email' => $this->faker->safeEmail ]); $this->company = Company::factory()->create([ 'account_id' => $this->account->id ]); $this->client = Client::factory()->create([ 'user_id' => $this->user->id, 'company_id' => $this->company->id ]); $this->primary_contact = ClientContact::factory()->create([ 'user_id' => $this->user->id, 'client_id' => $this->client->id, 'company_id' => $this->company->id, 'is_primary' => 1, ]); ClientContact::factory()->count(2)->create([ 'user_id' => $this->user->id, 'client_id' => $this->client->id, 'company_id' => $this->company->id, ]); } }