Deploy Ladill Queue / deploy (push) Successful in 1m53s
Seed branches, queues, counters, and tickets with plan-aware limits and reset. Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Qms\DemoSeeder;
|
|
use App\Services\Qms\PlanService;
|
|
use Illuminate\Console\Command;
|
|
|
|
/**
|
|
* Seed plan-aware Queue (QMS) demo data for a platform identity (email or public_id).
|
|
*/
|
|
class DemoSeedCommand extends Command
|
|
{
|
|
protected $signature = 'demo:seed
|
|
{identity : Email or public_id of the local User mirror}
|
|
{--plan=free : free|pro|enterprise}
|
|
{--reset : Wipe tenant-scoped demo data before reseeding}';
|
|
|
|
protected $description = 'Seed realistic Queue demo data for a Free/Pro/Enterprise account';
|
|
|
|
public function handle(DemoSeeder $seeder, PlanService $plans): int
|
|
{
|
|
$identity = (string) $this->argument('identity');
|
|
$plan = strtolower((string) $this->option('plan'));
|
|
$reset = (bool) $this->option('reset');
|
|
|
|
if (! in_array($plan, ['free', 'pro', 'enterprise'], true)) {
|
|
$this->error('Invalid --plan. Use free, pro, or enterprise.');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
try {
|
|
$result = $seeder->seed($identity, $plan, $reset);
|
|
} catch (\InvalidArgumentException $e) {
|
|
$this->error($e->getMessage());
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$user = $result['user'];
|
|
$org = $result['organization'];
|
|
$effective = $plans->planKey($org);
|
|
|
|
$this->info(sprintf(
|
|
'Seeded Queue demo for %s (%s) org=%s plan=%s (effective=%s)%s',
|
|
$user->email,
|
|
$user->public_id,
|
|
$org->name,
|
|
$result['plan'],
|
|
$effective,
|
|
$reset ? ' [reset]' : '',
|
|
));
|
|
|
|
$this->table(
|
|
['Metric', 'Count'],
|
|
collect($result['counts'])->map(fn ($v, $k) => [$k, (string) $v])->values()->all()
|
|
);
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|