*/ class SupplierFactory extends Factory { protected $model = Supplier::class; public function definition(): array { return [ 'name' => $this->faker->company(), 'url' => $this->faker->optional()->url(), 'contact_person' => $this->faker->optional()->name(), 'email' => $this->faker->optional()->companyEmail(), 'phone' => $this->faker->optional()->phoneNumber(), 'country_id' => Country::query()->value('id') ?? $this->resolveCountryId(), 'notes' => null, 'active' => true, ]; } protected function resolveCountryId(): int { $country = Country::query()->firstOrCreate( ['code' => 'TE'], [ 'phone' => '00', 'en' => 'Testland', 'de' => 'Testland', 'es' => 'Testland', 'fr' => 'Testland', 'it' => 'Testland', 'ru' => 'Testland', 'active' => true, ] ); return (int) $country->id; } }