Дополнительная информация о проекте в отчете
This commit is contained in:
parent
1a250c4b00
commit
f7ea110e33
@ -98,6 +98,11 @@ class Reports extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
|
||||
}
|
||||
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::class, ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
@ -120,7 +125,7 @@ class Reports extends \yii\db\ActiveRecord
|
||||
$taskModel->report_id = $this->id;
|
||||
$taskModel->task = $task['task'];
|
||||
$taskModel->hours_spent = (float)$task['hours_spent'];
|
||||
$taskModel->minutes_spent = (int) $task['minutes_spent'];
|
||||
$taskModel->minutes_spent = (int)$task['minutes_spent'];
|
||||
$taskModel->status = 1;
|
||||
$taskModel->created_at = time();
|
||||
$taskModel->save();
|
||||
|
@ -4,8 +4,9 @@
|
||||
namespace frontend\modules\api\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\Reports;
|
||||
use yii\base\Model;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/** */
|
||||
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) {
|
||||
$queryBuilder->andWhere(['between', 'reports.created_at', $this->fromDate, $this->toDate]);
|
||||
@ -58,7 +62,7 @@ class ReportSearchForm extends Model
|
||||
// $queryBuilder->limit($this->limit)
|
||||
// ->offset($this->offset);
|
||||
|
||||
return $queryBuilder->asArray()->all();
|
||||
return $queryBuilder->all();
|
||||
}
|
||||
|
||||
public function findByDate()
|
||||
|
@ -136,6 +136,10 @@ namespace frontend\modules\api\models;
|
||||
* property="task",
|
||||
* 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
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'difficulties',
|
||||
'tomorrow',
|
||||
'created_at',
|
||||
'status',
|
||||
'user_card_id',
|
||||
'user_id',
|
||||
'project_id',
|
||||
'project',
|
||||
'company_id',
|
||||
'task',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user