Initialer Laravel Commit für BetiX
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
2026-04-04 18:01:50 +02:00
commit 0280278978
374 changed files with 65210 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Console\Commands;
use App\Models\OperatorCasino;
use Illuminate\Console\Command;
class OperatorCreateCasino extends Command
{
protected $signature = 'operator:create-casino
{name : Display name of the casino / operator}
{--ip=* : Allowed IP addresses (repeat for multiple)}
{--domain=* : Allowed domains (repeat for multiple)}';
protected $description = 'Create a new B2B operator casino account and generate a betix_... license key';
public function handle(): int
{
$name = $this->argument('name');
// Generate key in format betix_{64 hex chars}
$licenseKey = 'betix_' . bin2hex(random_bytes(32));
$ipWhitelist = array_filter($this->option('ip'));
$domainWhitelist = array_filter($this->option('domain'));
$casino = OperatorCasino::create([
'name' => $name,
'license_key_hash' => hash('sha256', $licenseKey),
'status' => 'active',
'ip_whitelist' => !empty($ipWhitelist) ? array_values($ipWhitelist) : null,
'domain_whitelist' => !empty($domainWhitelist) ? array_values($domainWhitelist) : null,
]);
$this->newLine();
$this->components->success("Operator casino created: [{$casino->id}] {$casino->name}");
$this->newLine();
$this->components->warn('⚠ Save this license key — it will NOT be shown again:');
$this->line('');
$this->line(" <fg=green;options=bold>{$licenseKey}</>");
$this->line('');
if (!empty($casino->ip_whitelist)) {
$this->line('IP whitelist: ' . implode(', ', $casino->ip_whitelist));
}
if (!empty($casino->domain_whitelist)) {
$this->line('Domain whitelist: ' . implode(', ', $casino->domain_whitelist));
}
$this->newLine();
return self::SUCCESS;
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class ReencryptUserData extends Command
{
protected $signature = 'data:reencrypt-users {--chunk=500}';
protected $description = 'Re-read and re-save user fields to normalize encryption and blind indices';
public function handle(): int
{
$chunk = (int) $this->option('chunk');
$updated = 0;
// We want small transactions per chunk to avoid long locks
User::query()->orderBy('id')
->chunkById($chunk, function ($users) use (&$updated) {
DB::transaction(function () use ($users, &$updated) {
foreach ($users as $u) {
// Read via casts (plaintext) and assign back to trigger normalization
$email = $u->email;
$username = $u->username;
$dirty = false;
if ($email !== null) { $u->email = $email; $dirty = true; }
if ($username !== null) { $u->username = $username; $dirty = true; }
if ($dirty) {
$u->saveQuietly();
$updated++;
}
}
});
});
$this->info("Users normalized: {$updated}");
$this->info('Tip: Remove APP_PREVIOUS_KEYS after normalization if keys are unified.');
return self::SUCCESS;
}
}