Merge pull request #32 from apuc/sum_and_calendar

fix parameters error
This commit is contained in:
kavalar 2020-01-23 16:57:04 +03:00 committed by GitHub
commit 7585a9c04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -49,13 +49,15 @@ class UserCardController extends Controller
$total = 0;
if(Yii::$app->request->queryParams)
foreach (Yii::$app->request->queryParams as $params)
foreach (Yii::$app->request->queryParams as $params) {
$total = \common\models\UserCard::find()->filterWhere([
'fio' => $params['fio'],
'email' => $params['email'],
'status' => $params['status'],
'skills' => $params['skills'],
'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', [

View File

@ -158,4 +158,13 @@ class UserCard extends \common\models\UserCard
if ($user_card_array) return "Данные успешно сгенерированы";
else return "Нет данных для генерации";
}
public static function getParameter($params, $key)
{
try {
return $params[$key];
} catch (\Exception $e) {
return '';
}
}
}