Allow explicit multi-branch practitioner assignment for telemedicine.
Deploy Ladill Care / deploy (push) Successful in 1m29s

Replace optional “All branches” with required branch checkboxes; doctors may switch only among assigned sites, never org-wide by default.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 08:50:03 +00:00
co-authored by Cursor
parent d643687335
commit 899b08179e
17 changed files with 478 additions and 103 deletions
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('care_practitioner_branch', function (Blueprint $table) {
$table->id();
$table->foreignId('practitioner_id')->constrained('care_practitioners')->cascadeOnDelete();
$table->foreignId('branch_id')->constrained('care_branches')->cascadeOnDelete();
$table->timestamps();
$table->unique(['practitioner_id', 'branch_id']);
});
// Backfill explicit assignments from the legacy single branch_id (never invent "all branches").
$now = now();
foreach (DB::table('care_practitioners')->whereNotNull('branch_id')->get(['id', 'branch_id']) as $row) {
DB::table('care_practitioner_branch')->insertOrIgnore([
'practitioner_id' => $row->id,
'branch_id' => $row->branch_id,
'created_at' => $now,
'updated_at' => $now,
]);
}
}
public function down(): void
{
Schema::dropIfExists('care_practitioner_branch');
}
};