diff --git a/app/Services/Care/DemoTenantSeeder.php b/app/Services/Care/DemoTenantSeeder.php index 162cd5a..acb2bc8 100644 --- a/app/Services/Care/DemoTenantSeeder.php +++ b/app/Services/Care/DemoTenantSeeder.php @@ -1089,8 +1089,17 @@ class DemoTenantSeeder private function seedDentistryClinicalDemo(Organization $organization, string $ownerRef): void { - $departmentIds = Department::owned($ownerRef) + // Specialty departments are provisioned without organization_id; scope via branches. + $branchIds = Branch::owned($ownerRef) ->where('organization_id', $organization->id) + ->pluck('id'); + + if ($branchIds->isEmpty()) { + return; + } + + $departmentIds = Department::owned($ownerRef) + ->whereIn('branch_id', $branchIds) ->where('type', 'dental') ->where('is_active', true) ->pluck('id');