From 9ecc3ad7f0118e67093cd09e7030a2330c62e94e Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sat, 18 Jul 2026 21:56:18 +0000 Subject: [PATCH] Fix dentistry demo seed scoping departments by branch. care_departments has no organization_id; match the Blood Bank seeder pattern so demo:seed no longer fails on dental specialty data. Co-authored-by: Cursor --- app/Services/Care/DemoTenantSeeder.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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');