調整 API 包帳 排序

This commit is contained in:
allen.yan 2025-07-24 11:17:04 +08:00
parent 79cf1b920b
commit f3eaa9c715

View File

@ -67,7 +67,9 @@ class BranchControlController extends Controller
*/
public function Branches(Request $request): JsonResponse
{
$branches = Branch::with('rooms')->orderBy('name', 'asc')->get()->map(function ($branch) {
$branches = Branch::with(['rooms' => function ($query) {
$query->orderBy('name', 'asc'); // 對 rooms 的 name 排序
}])->get()->map(function ($branch) {
return [
'id' => $branch->id,
'branch_name' => $branch->name,