Label multi-branch department picks and add searchable patients.
Deploy Ladill Care / deploy (push) Successful in 27s
Deploy Ladill Care / deploy (push) Successful in 27s
Make appointment/practitioner department (and practitioner) options show branch names so duplicates are distinguishable, and replace the patient select with a searchable dropdown. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -276,10 +276,12 @@ class AppointmentController extends Controller
|
||||
->get();
|
||||
|
||||
$departments = Department::owned($ownerRef)
|
||||
->with('branch')
|
||||
->whereIn('branch_id', $branches->pluck('id'))
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
->get()
|
||||
->sortBy(fn (Department $d) => strtolower(($d->branch?->name ?? '').' '.$d->name))
|
||||
->values();
|
||||
|
||||
return [
|
||||
'organization' => $organization,
|
||||
@@ -297,6 +299,7 @@ class AppointmentController extends Controller
|
||||
protected function activePractitioners(Request $request, int $organizationId)
|
||||
{
|
||||
return Practitioner::owned($this->ownerRef($request))
|
||||
->with(['branch', 'branches'])
|
||||
->where('organization_id', $organizationId)
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
|
||||
@@ -186,10 +186,12 @@ class PractitionerController extends Controller
|
||||
protected function activeDepartments(string $owner, int $organizationId)
|
||||
{
|
||||
return Department::owned($owner)
|
||||
->with('branch')
|
||||
->whereHas('branch', fn ($q) => $q->where('organization_id', $organizationId))
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
->get()
|
||||
->sortBy(fn (Department $d) => strtolower(($d->branch?->name ?? '').' '.$d->name))
|
||||
->values();
|
||||
}
|
||||
|
||||
protected function linkableMembers(string $owner, int $organizationId)
|
||||
|
||||
@@ -26,4 +26,20 @@ class Department extends Model
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Select option label — includes branch when set so multi-branch duplicates are distinguishable.
|
||||
*/
|
||||
public function labelForSelect(): string
|
||||
{
|
||||
$branch = $this->relationLoaded('branch')
|
||||
? $this->branch
|
||||
: $this->branch()->first();
|
||||
|
||||
if ($branch?->name) {
|
||||
return $this->name.' — '.$branch->name;
|
||||
}
|
||||
|
||||
return (string) $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,30 @@ class Practitioner extends Model
|
||||
return $this->hasMany(Appointment::class, 'practitioner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Select option label — includes branch context when available.
|
||||
*/
|
||||
public function labelForSelect(): string
|
||||
{
|
||||
$branchNames = [];
|
||||
if ($this->relationLoaded('branches') && $this->branches->isNotEmpty()) {
|
||||
$branchNames = $this->branches->pluck('name')->filter()->values()->all();
|
||||
} elseif ($this->relationLoaded('branch') && $this->branch?->name) {
|
||||
$branchNames = [$this->branch->name];
|
||||
} elseif ($this->branch_id) {
|
||||
$name = $this->branch()?->value('name');
|
||||
if ($name) {
|
||||
$branchNames = [$name];
|
||||
}
|
||||
}
|
||||
|
||||
if ($branchNames === []) {
|
||||
return (string) $this->name;
|
||||
}
|
||||
|
||||
return $this->name.' — '.implode(', ', $branchNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user