Seed DemoWorld business, staff, and guest continuity for Meet demos
Deploy Ladill Meet / deploy (push) Successful in 2m10s
Deploy Ladill Meet / deploy (push) Successful in 2m10s
Organization and branch names now come from DemoWorld business/branch catalogs, meet-role staff are mirrored as Members by email until SSO remaps to public_id, and guest participants use DemoWorld people for cross-app continuity. Staff logins skip the login reseed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,8 +9,10 @@ use App\Models\Participant;
|
||||
use App\Models\Room;
|
||||
use App\Models\Session;
|
||||
use App\Models\User;
|
||||
use App\Support\DemoWorld;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
@@ -63,8 +65,9 @@ class DemoSeedCommand extends Command
|
||||
|
||||
$volume = $this->volumeFor($plan);
|
||||
$org = $this->ensureOrganization($user, $plan);
|
||||
$branches = $this->ensureBranches($org, $ownerRef, $volume['branches']);
|
||||
$branches = $this->ensureBranches($org, $ownerRef, $plan, $volume['branches']);
|
||||
$this->ensureOwnerMember($org, $ownerRef, $branches->first()?->id);
|
||||
$this->seedStaffMembers($org, $ownerRef, $plan, $branches->first()?->id);
|
||||
$this->seedRoomsAndSessions($org, $ownerRef, $branches, $volume);
|
||||
|
||||
$this->info(sprintf(
|
||||
@@ -146,6 +149,7 @@ class DemoSeedCommand extends Command
|
||||
private function ensureOrganization(User $user, string $plan): Organization
|
||||
{
|
||||
$slug = 'demo-'.Str::slug(Str::before($user->email, '@') ?: $user->public_id);
|
||||
$business = DemoWorld::business($plan);
|
||||
|
||||
return Organization::query()->updateOrCreate(
|
||||
[
|
||||
@@ -153,7 +157,7 @@ class DemoSeedCommand extends Command
|
||||
'slug' => $slug,
|
||||
],
|
||||
[
|
||||
'name' => $user->name.' Demo Org',
|
||||
'name' => $business['name'],
|
||||
'timezone' => 'Africa/Accra',
|
||||
'license_tier' => 'standard',
|
||||
'settings' => [
|
||||
@@ -168,21 +172,25 @@ class DemoSeedCommand extends Command
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection<int, Branch>
|
||||
*/
|
||||
private function ensureBranches(Organization $org, string $ownerRef, int $count)
|
||||
private function ensureBranches(Organization $org, string $ownerRef, string $plan, int $count)
|
||||
{
|
||||
$catalog = DemoWorld::branches($plan, $count);
|
||||
$branches = collect();
|
||||
$names = ['Head Office', 'East Branch', 'West Branch'];
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$branches->push(Branch::query()->updateOrCreate(
|
||||
foreach ($catalog as $i => $spec) {
|
||||
$code = $spec['code'] !== '' ? $spec['code'] : 'DEMO-'.($i + 1);
|
||||
$branches->push(Branch::withTrashed()->updateOrCreate(
|
||||
[
|
||||
'organization_id' => $org->id,
|
||||
'code' => 'DEMO-'.($i + 1),
|
||||
'code' => $code,
|
||||
],
|
||||
[
|
||||
'owner_ref' => $ownerRef,
|
||||
'name' => $names[$i] ?? ('Branch '.($i + 1)),
|
||||
'name' => $spec['name'],
|
||||
'address' => $spec['address'],
|
||||
'phone' => $spec['phone'],
|
||||
'is_active' => true,
|
||||
'deleted_at' => null,
|
||||
],
|
||||
));
|
||||
}
|
||||
@@ -205,6 +213,44 @@ class DemoSeedCommand extends Command
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirror DemoWorld staff with a `meet` role as local Member rows, keyed
|
||||
* by staff email until SSO login remaps user_ref to the real public_id.
|
||||
*/
|
||||
private function seedStaffMembers(Organization $org, string $ownerRef, string $plan, ?int $branchId): void
|
||||
{
|
||||
foreach (DemoWorld::staff($plan) as $staff) {
|
||||
$role = $staff['roles']['meet'] ?? null;
|
||||
if (! is_string($role) || $role === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = strtolower(trim($staff['email']));
|
||||
|
||||
User::query()->firstOrCreate(
|
||||
['email' => $email],
|
||||
[
|
||||
'public_id' => (string) Str::uuid(),
|
||||
'name' => $staff['name'],
|
||||
'password' => Hash::make(config('demo_accounts.password', DemoWorld::DEFAULT_PASSWORD)),
|
||||
'email_verified_at' => now(),
|
||||
],
|
||||
);
|
||||
|
||||
Member::query()->updateOrCreate(
|
||||
[
|
||||
'organization_id' => $org->id,
|
||||
'user_ref' => $email,
|
||||
],
|
||||
[
|
||||
'owner_ref' => $ownerRef,
|
||||
'role' => $role,
|
||||
'branch_id' => $branchId,
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Support\Collection<int, Branch> $branches
|
||||
* @param array{branches: int, rooms: int, past_sessions: int, upcoming: int, participants: int} $volume
|
||||
@@ -284,13 +330,15 @@ class DemoSeedCommand extends Command
|
||||
'left_at' => $left ? $session->ended_at : null,
|
||||
]);
|
||||
|
||||
$guests = DemoWorld::people($count - 1);
|
||||
for ($i = 1; $i < $count; $i++) {
|
||||
$guest = $guests[$i - 1] ?? null;
|
||||
Participant::query()->create([
|
||||
'owner_ref' => $ownerRef,
|
||||
'session_id' => $session->id,
|
||||
'user_ref' => null,
|
||||
'display_name' => 'Demo Guest '.$i,
|
||||
'email' => 'guest'.$i.'@example.com',
|
||||
'display_name' => $guest ? DemoWorld::fullName($guest) : 'Demo Guest '.$i,
|
||||
'email' => $guest['email'] ?? ('guest'.$i.'@example.com'),
|
||||
'role' => 'participant',
|
||||
'status' => $left ? 'left' : 'joined',
|
||||
'joined_at' => $session->started_at?->copy()->addMinutes($i),
|
||||
|
||||
Reference in New Issue
Block a user