create report fix

This commit is contained in:
Kavalar 2024-02-01 23:58:47 +03:00
parent 51b34ade1f
commit 2337bd75a1

View File

@ -261,6 +261,10 @@ class ReportsController extends ApiController
$params['created_at'] = date("Y-m-d");
}
if (Reports::find()->where(['created_at' => $params['created_at'], 'user_id' => $params['user_id']])->exists()) {
throw new BadRequestHttpException('Этот пользователь уже заполнил отчет в этот день');
}
$reportsModel = new Reports();
$reportsModel->attributes = $params;
if (!$reportsModel->validate() || !$reportsModel->save()) {