37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Str;
|
|
use Infra\Database\Models\ApiClient;
|
|
|
|
final class ApiClientSeeder extends Seeder
|
|
{
|
|
public function run(): void
|
|
{
|
|
/** @var array{id: string, name: string, identifier: string, secret: string} $devClient */
|
|
$devClient = Config::array('auth.hmac.dev_client');
|
|
$now = now();
|
|
|
|
ApiClient::query()->updateOrCreate(
|
|
['identifier' => $devClient['identifier']],
|
|
[
|
|
'id' => $devClient['id'],
|
|
'name' => $devClient['name'],
|
|
'slug' => Str::slug($devClient['name']),
|
|
'secret' => $devClient['secret'],
|
|
'is_active' => true,
|
|
'updated_at' => $now,
|
|
]
|
|
);
|
|
|
|
$this->command?->info('API client seeded successfully.');
|
|
$this->command?->info('Client ID: ' . $devClient['id']);
|
|
$this->command?->info('Client Identifier: ' . $devClient['identifier']);
|
|
$this->command?->info('Client Secret: ' . $devClient['secret']);
|
|
}
|
|
}
|