Дополнительная информация о проекте в отчете

This commit is contained in:
Kavalar 2024-02-15 23:48:44 +03:00
parent 1a250c4b00
commit f7ea110e33
3 changed files with 37 additions and 5 deletions

View File

@ -98,6 +98,11 @@ class Reports extends \yii\db\ActiveRecord
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']); return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
} }
public function getProject()
{
return $this->hasOne(Project::class, ['id' => 'project_id']);
}
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */

View File

@ -4,8 +4,9 @@
namespace frontend\modules\api\models; namespace frontend\modules\api\models;
use common\classes\Debug; use common\classes\Debug;
use common\models\Reports;
use yii\base\Model; use yii\base\Model;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
/** */ /** */
class ReportSearchForm extends Model class ReportSearchForm extends Model
@ -43,9 +44,12 @@ class ReportSearchForm extends Model
]; ];
} }
public function byParams() /**
* @return array|ActiveRecord
*/
public function byParams(): array | ActiveRecord
{ {
$queryBuilder = Reports::find()->with('task'); $queryBuilder = Reports::find();
if ($this->fromDate && $this->toDate) { if ($this->fromDate && $this->toDate) {
$queryBuilder->andWhere(['between', 'reports.created_at', $this->fromDate, $this->toDate]); $queryBuilder->andWhere(['between', 'reports.created_at', $this->fromDate, $this->toDate]);
@ -58,7 +62,7 @@ class ReportSearchForm extends Model
// $queryBuilder->limit($this->limit) // $queryBuilder->limit($this->limit)
// ->offset($this->offset); // ->offset($this->offset);
return $queryBuilder->asArray()->all(); return $queryBuilder->all();
} }
public function findByDate() public function findByDate()

View File

@ -136,6 +136,10 @@ namespace frontend\modules\api\models;
* property="task", * property="task",
* ref="#/components/schemas/ProjectTaskReportsExample", * ref="#/components/schemas/ProjectTaskReportsExample",
* ), * ),
* @OA\Property(
* property="project",
* ref="#/components/schemas/ProjectExample",
* ),
* ), * ),
*) *)
* *
@ -143,4 +147,23 @@ namespace frontend\modules\api\models;
class Reports extends \common\models\Reports class Reports extends \common\models\Reports
{ {
/**
* @return string[]
*/
public function fields(): array
{
return [
'difficulties',
'tomorrow',
'created_at',
'status',
'user_card_id',
'user_id',
'project_id',
'project',
'company_id',
'task',
];
}
} }