Merge pull request 'Bổ sung sort theo ngày mới nhất' (#90) from Sprint-4/MS-37-FE-Evaluation into master

Reviewed-on: #90
This commit is contained in:
vincent.vo 2024-09-24 19:23:42 +10:00
commit ba3209d473
1 changed files with 2 additions and 5 deletions

View File

@ -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']) {