Wire Frontdesk demo seeder to shared DemoWorld
Deploy Ladill Frontdesk / deploy (push) Successful in 1m10s

Org name, branches, and visitors now come from DemoWorld so continuity
matches Care/Queue across the suite, plus Members for DemoWorld staff
with a frontdesk role. Also resolve organization by owner_ref when
metadata.frontdesk.organization_id is missing, and skip reseed-on-login
for DemoWorld staff emails.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 13:35:52 +00:00
co-authored by Cursor
parent 1c0b5fdce7
commit a28e8619a1
5 changed files with 648 additions and 12 deletions
+44 -11
View File
@@ -22,6 +22,7 @@ use App\Models\Visitor;
use App\Models\WatchlistEntry;
use App\Models\WebhookEndpoint;
use App\Services\Frontdesk\PlanService;
use App\Support\DemoWorld;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
@@ -145,7 +146,7 @@ class DemoSeedCommand extends Command
}
$org->fill([
'name' => $plan === 'enterprise' ? 'Accra Healthcare Group Frontdesk' : 'Ladill Demo Frontdesk',
'name' => DemoWorld::business($plan)['name'],
'timezone' => 'Africa/Accra',
'settings' => array_merge((array) ($org->settings ?? []), $settings),
]);
@@ -166,6 +167,35 @@ class DemoSeedCommand extends Command
return $org->fresh();
}
/**
* Local Member rows for DemoWorld staff with a frontdesk role (user_ref =
* email until SSO remaps to public_id).
*
* @param list<Branch> $branches
*/
private function seedStaffMembers(string $ownerRef, Organization $organization, string $plan, array $branches): void
{
$hq = $branches[0] ?? null;
foreach (DemoWorld::staff($plan) as $staff) {
$role = $staff['roles']['frontdesk'] ?? null;
if (! is_string($role) || $role === '') {
continue;
}
Member::query()->updateOrCreate(
[
'organization_id' => $organization->id,
'user_ref' => strtolower($staff['email']),
],
[
'owner_ref' => $ownerRef,
'role' => $role,
'branch_id' => $hq?->id,
],
);
}
}
private function hasDemoVisits(Organization $organization): bool
{
return Visit::query()
@@ -239,19 +269,20 @@ class DemoSeedCommand extends Command
$visitorCount = $paid ? 30 : 15;
$branches = [];
$names = ['HQ', 'East Legon', 'Airport', 'Tema'];
for ($i = 0; $i < $branchCount; $i++) {
foreach (DemoWorld::branches($plan, $branchCount) as $spec) {
$branches[] = Branch::query()->create([
'owner_ref' => $ownerRef,
'organization_id' => $organization->id,
'name' => $names[$i] ?? ('Branch '.($i + 1)),
'code' => 'BR'.($i + 1),
'address' => 'Accra branch address '.($i + 1),
'phone' => '+23330200000'.($i + 1),
'name' => $spec['name'],
'code' => $spec['code'],
'address' => $spec['address'],
'phone' => $spec['phone'],
'is_active' => true,
]);
}
$this->seedStaffMembers($ownerRef, $organization, $plan, $branches);
$hosts = [];
$desks = [];
foreach ($branches as $index => $branch) {
@@ -310,15 +341,17 @@ class DemoSeedCommand extends Command
]);
}
$people = DemoWorld::people();
$visitors = [];
for ($v = 1; $v <= $visitorCount; $v++) {
$person = $people[($v - 1) % count($people)];
$visitors[] = Visitor::query()->create([
'owner_ref' => $ownerRef,
'organization_id' => $organization->id,
'full_name' => 'Visitor '.$v,
'company' => 'Guest Co '.$v,
'phone' => '+23355'.str_pad((string) $v, 7, '0', STR_PAD_LEFT),
'email' => 'visitor'.$v.'@demo.ladill.com',
'full_name' => DemoWorld::fullName($person),
'company' => DemoWorld::companyNameForPerson($person),
'phone' => $person['phone'],
'email' => $person['email'],
'watchlist_status' => Visitor::WATCHLIST_ALLOWED,
'visit_count' => 0,
'is_frequent' => $v <= 3,