Files
keystone/database/factories/ProviderFactory.php
2025-04-07 19:06:37 +01:00

37 lines
901 B
PHP

<?php
namespace Database\Factories;
use App\Enums\ProviderType;
use App\Models\Organisation;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Provider>
*/
class ProviderFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => 'keystone',
'type' => $this->faker->randomElement([
ProviderType::HETZNER,
]),
'token' => $this->faker->uuid(),
];
}
public function forOrganisation(string|Organisation $organisation): static
{
return $this->state(fn (array $attributes) => [
'organisation_id' => is_string($organisation) ? $organisation : $organisation->id,
]);
}
}