diff --git a/BACKEND/Modules/Admin/app/Http/Controllers/TechnicalController.php b/BACKEND/Modules/Admin/app/Http/Controllers/TechnicalController.php index 2e3cf74..79ae33c 100644 --- a/BACKEND/Modules/Admin/app/Http/Controllers/TechnicalController.php +++ b/BACKEND/Modules/Admin/app/Http/Controllers/TechnicalController.php @@ -119,6 +119,7 @@ class TechnicalController extends Controller ->where('user_id', $userId) ->where('point', '>', 0) ->orderBy('point', 'desc') + ->orderBy('updated_at', 'desc') ->get(); if ($technicals->isEmpty()) { return []; @@ -221,14 +222,10 @@ class TechnicalController extends Controller 'technicals.*.point' => 'required|integer|min:0|max:3', // Điểm trong khoảng [0-3] ]); - // Lấy danh sách technicals của user từ bảng TechnicalUser $existingTechnicals = TechnicalUser::where('user_id', $userInfo->id)->get()->keyBy('technical_id'); - + foreach ($validatedData['technicals'] as $technical) { $existingTechnical = $existingTechnicals->get($technical['technical_id']); - // if ($technical['technical_id'] == 7) { - // dd($existingTechnical,$userInfo); - // } if ($existingTechnical) { // Nếu technical_id đã tồn tại và point khác, thì update if ($existingTechnical->point !== $technical['point']) {