total in serch model

This commit is contained in:
akosse
2020-01-23 17:14:53 +03:00
parent 3de2cb7a4a
commit 3daeae0293
3 changed files with 6 additions and 16 deletions

View File

@ -47,23 +47,9 @@ class UserCardController extends Controller
$searchModel = new UserCardSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$total = 0;
if(Yii::$app->request->queryParams)
foreach (Yii::$app->request->queryParams as $params) {
$total = \common\models\UserCard::find()->filterWhere([
'fio' => UserCard::getParameter($params, 'fio'),
'email' => UserCard::getParameter($params, 'email'),
'status' => UserCard::getParameter($params, 'status'),
'skills' => UserCard::getParameter($params, 'skills'),
])->sum('salary');
}
else $total = \common\models\UserCard::find()->sum('salary');
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'total' => $total,
]);
}