tmp commit
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "document".
|
||||
@ -12,14 +14,23 @@ use Yii;
|
||||
* @property int $contractor_company_id
|
||||
* @property int $manager_id
|
||||
* @property int $contractor_manager_id
|
||||
* @property int $template_id
|
||||
* @property string $title
|
||||
* @property string $body
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property Company $company
|
||||
* @property Company $contractorCompany
|
||||
* @property Manager $contractorManager
|
||||
* @property DocumentTemplate $template
|
||||
* @property Manager $manager
|
||||
*/
|
||||
class Document extends \yii\db\ActiveRecord
|
||||
{
|
||||
const SCENARIO_GENERATE_DOCUMENT_BODY = 'generate_document_body';
|
||||
const SCENARIO_UPDATE_DOCUMENT_BODY = 'update_document_body';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -28,18 +39,37 @@ class Document extends \yii\db\ActiveRecord
|
||||
return 'document';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['company_id', 'manager_id', 'contractor_manager_id'], 'required'],
|
||||
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id'], 'integer'],
|
||||
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'title', 'template_id'], 'required'],
|
||||
[['company_id', 'contractor_company_id', 'manager_id', 'contractor_manager_id', 'template_id'], 'integer'],
|
||||
[['body'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['company_id' => 'id']],
|
||||
[['contractor_company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::className(), 'targetAttribute' => ['contractor_company_id' => 'id']],
|
||||
[['contractor_manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['contractor_manager_id' => 'id']],
|
||||
[['template_id'], 'exist', 'skipOnError' => true, 'targetClass' => DocumentTemplate::className(), 'targetAttribute' => ['template_id' => 'id']],
|
||||
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
|
||||
// ['resumeTemplateId', 'required', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
|
||||
// ['resumeTemplateId', 'integer', 'on' => self::SCENARIO_GENERATE_RESUME_TEXT],
|
||||
['body', 'required', 'on' => self::SCENARIO_UPDATE_DOCUMENT_BODY],
|
||||
];
|
||||
}
|
||||
|
||||
@ -50,13 +80,26 @@ class Document extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'company_id' => 'Company ID',
|
||||
'contractor_company_id' => 'Contractor Company ID',
|
||||
'manager_id' => 'Manager ID',
|
||||
'contractor_manager_id' => 'Contractor Manager ID',
|
||||
'company_id' => 'Компания',
|
||||
'contractor_company_id' => 'Компания контрагент',
|
||||
'manager_id' => 'Менеджер',
|
||||
'contractor_manager_id' => 'Менеджер контрагент',
|
||||
'template_id' => 'Шаблон документа',
|
||||
'title' => 'Название',
|
||||
'body' => 'Тело документа',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getTemplate()
|
||||
{
|
||||
return $this->hasOne(DocumentTemplate::className(), ['id' => 'template_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "document_template".
|
||||
@ -10,6 +12,9 @@ use Yii;
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $template_body
|
||||
* @property int $status
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class DocumentTemplate extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -21,13 +26,28 @@ class DocumentTemplate extends \yii\db\ActiveRecord
|
||||
return 'document_template';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['status', 'title', 'template_body'], 'required'],
|
||||
[['template_body'], 'string'],
|
||||
[['status'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
@ -39,8 +59,11 @@ class DocumentTemplate extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'title' => 'Title',
|
||||
'template_body' => 'Template Body',
|
||||
'title' => 'Название',
|
||||
'template_body' => 'Тело шаблона',
|
||||
'status' => 'Статус',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user