Merge pull request 'master' (#91) from master into dev
Reviewed-on: #91
This commit is contained in:
commit
0b823a226c
|
|
@ -119,6 +119,7 @@ class TechnicalController extends Controller
|
||||||
->where('user_id', $userId)
|
->where('user_id', $userId)
|
||||||
->where('point', '>', 0)
|
->where('point', '>', 0)
|
||||||
->orderBy('point', 'desc')
|
->orderBy('point', 'desc')
|
||||||
|
->orderBy('updated_at', 'desc')
|
||||||
->get();
|
->get();
|
||||||
if ($technicals->isEmpty()) {
|
if ($technicals->isEmpty()) {
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -221,14 +222,10 @@ class TechnicalController extends Controller
|
||||||
'technicals.*.point' => 'required|integer|min:0|max:3', // Điểm trong khoảng [0-3]
|
'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');
|
$existingTechnicals = TechnicalUser::where('user_id', $userInfo->id)->get()->keyBy('technical_id');
|
||||||
|
|
||||||
foreach ($validatedData['technicals'] as $technical) {
|
foreach ($validatedData['technicals'] as $technical) {
|
||||||
$existingTechnical = $existingTechnicals->get($technical['technical_id']);
|
$existingTechnical = $existingTechnicals->get($technical['technical_id']);
|
||||||
// if ($technical['technical_id'] == 7) {
|
|
||||||
// dd($existingTechnical,$userInfo);
|
|
||||||
// }
|
|
||||||
if ($existingTechnical) {
|
if ($existingTechnical) {
|
||||||
// Nếu technical_id đã tồn tại và point khác, thì update
|
// Nếu technical_id đã tồn tại và point khác, thì update
|
||||||
if ($existingTechnical->point !== $technical['point']) {
|
if ($existingTechnical->point !== $technical['point']) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue