40 lines
1 KiB
PHP
40 lines
1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Application\Security\Ports\Services\ClientCredentialGenerator;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
use Infra\Database\Models\ApiClient;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
/**
|
|
* @extends Factory<ApiClient>
|
|
*/
|
|
final class ApiClientFactory extends Factory
|
|
{
|
|
protected $model = ApiClient::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
#[\Override]
|
|
public function definition(): array
|
|
{
|
|
$clientIdentifierGenerator = resolve(ClientCredentialGenerator::class);
|
|
|
|
$name = fake()->company();
|
|
|
|
return [
|
|
'id' => Uuid::uuid7()->toString(),
|
|
'name' => $name,
|
|
'slug' => Str::slug($name),
|
|
'identifier' => $clientIdentifierGenerator->generateIdentifier()->value,
|
|
'secret' => $clientIdentifierGenerator->generateSecret()->value,
|
|
'is_active' => true,
|
|
'updated_at' => now(),
|
|
];
|
|
}
|
|
}
|