From 4c3930f5e6c549068268b4c960254dfa326493d2 Mon Sep 17 00:00:00 2001 From: andrey Date: Mon, 9 Aug 2021 18:23:56 +0300 Subject: [PATCH] user card sort --- backend/modules/card/controllers/UserCardController.php | 4 +++- backend/modules/card/models/UserCardSearch.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index f5c7501..df2d805 100755 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -152,7 +152,9 @@ class UserCardController extends Controller public function actionUpdate($id) { $model = $this->findModel($id); - if ($model->load(Yii::$app->request->post()) && $model->save()) { + if ($model->load(Yii::$app->request->post())) { + $model->updated_at = date('Y-m-d h:i:s'); + $model->save(); return $this->redirect(['view', 'id' => $model->id]); } diff --git a/backend/modules/card/models/UserCardSearch.php b/backend/modules/card/models/UserCardSearch.php index 2117709..a459119 100755 --- a/backend/modules/card/models/UserCardSearch.php +++ b/backend/modules/card/models/UserCardSearch.php @@ -83,7 +83,9 @@ class UserCardSearch extends UserCard $query->andFilterWhere(['skill.id' => $this->skills]); - $query->orderBy('user_card.created_at DESC'); + $query->orderBy('user_card.updated_at DESC'); + + $query->groupBy('card_skill.card_id'); $sumQuery = clone $query;