Files
ladill-pos/app/Console/Commands/DemoSeedCommand.php
T
isaaccladandCursor ff098c0a29
Deploy Ladill POS / deploy (push) Successful in 2m34s
Add POS demo:seed for register walkthroughs.
Seed locations, products, and cash sales within Free caps and Pro multi-site data.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 10:03:57 +00:00

61 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Services\Pos\DemoSeeder;
use App\Services\Pos\SubscriptionService;
use Illuminate\Console\Command;
/**
* Seed plan-aware POS 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 POS demo data for a Free/Pro/Enterprise account';
public function handle(DemoSeeder $seeder, SubscriptionService $subscriptions): 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'];
$effective = $subscriptions->planKey($user);
$this->info(sprintf(
'Seeded POS demo for %s (%s) plan=%s (effective=%s)%s',
$user->email,
$user->public_id,
$result['plan'],
$effective,
$reset ? ' [reset]' : '',
));
$this->table(
['Metric', 'Count'],
collect($result['counts'])->map(fn ($v, $k) => [$k, (string) $v])->values()->all()
);
return self::SUCCESS;
}
}