reports fix
This commit is contained in:
@ -14,6 +14,7 @@ use Yii;
|
||||
* @property string $difficulties
|
||||
* @property string $tomorrow
|
||||
* @property int $user_card_id
|
||||
* @property int $user_id
|
||||
* @property int $project_id
|
||||
* @property int $company_id
|
||||
* @property int $status
|
||||
@ -38,11 +39,12 @@ class Reports extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['user_card_id', 'status', 'company_id', 'project_id'], 'integer'],
|
||||
[['user_card_id', 'user_id', 'status', 'company_id', 'project_id'], 'integer'],
|
||||
[['_task'], 'checkIsArray'],
|
||||
[['user_card_id', 'created_at'], 'required'],
|
||||
[['created_at'], 'required'],
|
||||
[['today', 'difficulties', 'tomorrow', 'created_at'], 'string', 'max' => 255],
|
||||
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['user_card_id' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['project_id'], 'exist', 'skipOnEmpty' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['company_id'], 'exist', 'skipOnEmpty' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
||||
];
|
||||
@ -59,7 +61,8 @@ class Reports extends \yii\db\ActiveRecord
|
||||
'today' => 'Что было сделано сегодня?',
|
||||
'difficulties' => 'Какие сложности возникли?',
|
||||
'tomorrow' => 'Что планируется сделать завтра?',
|
||||
'user_card_id' => 'Пользователь',
|
||||
'user_card_id' => 'Профиль пользователя',
|
||||
'user_id' => 'Пользователь',
|
||||
'status' => 'Статус',
|
||||
'project_id' => 'ID проекта',
|
||||
'company_id' => 'ID компании'
|
||||
@ -95,6 +98,14 @@ class Reports extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
private function getUser(): \yii\db\ActiveQuery
|
||||
{
|
||||
return $this->hasOne(User::class, ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
public function getTask()
|
||||
{
|
||||
return $this->hasMany(ReportsTask::class, ['report_id' => 'id']);
|
||||
|
@ -19,14 +19,14 @@ use Yii;
|
||||
*/
|
||||
class ReportsTask extends \yii\db\ActiveRecord
|
||||
{
|
||||
const SCENARIO_WITHOUT_REPORT_ID = 'withoutReportID';
|
||||
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = parent::scenarios();
|
||||
$scenarios[self::SCENARIO_WITHOUT_REPORT_ID] = self::attributes();
|
||||
return $scenarios;
|
||||
}
|
||||
// const SCENARIO_WITHOUT_REPORT_ID = 'withoutReportID';
|
||||
//
|
||||
// public function scenarios()
|
||||
// {
|
||||
// $scenarios = parent::scenarios();
|
||||
// $scenarios[self::SCENARIO_WITHOUT_REPORT_ID] = self::attributes();
|
||||
// return $scenarios;
|
||||
// }
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -42,7 +42,7 @@ class ReportsTask extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['report_id'], 'required', 'on' => self::SCENARIO_DEFAULT],
|
||||
//[['report_id'], 'required', 'on' => self::SCENARIO_DEFAULT],
|
||||
[['report_id', 'created_at', 'status', 'minutes_spent'], 'integer'],
|
||||
[['hours_spent'], 'number'],
|
||||
['minutes_spent', 'compare', 'compareValue' => 60, 'operator' => '<'],
|
||||
|
Reference in New Issue
Block a user