add admin command

This commit is contained in:
Yisroel Baum 2026-07-02 01:21:04 +03:00
parent 4462879b7d
commit fee174ec05
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
7 changed files with 120 additions and 0 deletions

View file

@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands;
use App\User\InitialAdminCredentialsProvider;
use App\User\UseCases\EnsureInitialAdmin\EnsureInitialAdmin;
use App\User\UseCases\EnsureInitialAdmin\EnsureInitialAdminRequest;
use Illuminate\Console\Command;
class EnsureInitialAdminCommand extends Command
{
protected $signature = 'rabbi-gerzi:ensure-initial-admin';
protected $description = 'Create the configured initial admin if missing';
public function __construct(
private EnsureInitialAdmin $ensureInitialAdmin,
private InitialAdminCredentialsProvider $credentialsProvider,
) {
parent::__construct();
}
public function handle(): int
{
$credentials = $this->credentialsProvider->getCredentials();
$this->ensureInitialAdmin->execute(new EnsureInitialAdminRequest(
email: $credentials->getEmail(),
password: $credentials->getPassword(),
));
$this->info('initial admin is ready');
return self::SUCCESS;
}
}