project column

This commit is contained in:
2023-04-20 02:07:19 +03:00
parent edea2cc3e7
commit 2482ae89f6
24 changed files with 737 additions and 18 deletions

View File

@ -10,7 +10,7 @@ use yii\db\StaleObjectException;
* This is the model class for table "manager".
*
* @property int $id
* @property int $user_card_id
* @property int $user_id
*
* @property UserCard $userCard
* @property ManagerEmployee[] $managerEmployees
@ -31,10 +31,10 @@ class Manager extends \yii\db\ActiveRecord
public function rules()
{
return [
[['user_card_id'], 'integer'],
[['user_card_id'], 'required'],
['user_card_id', 'unique', 'message'=>'Уже является менеджером'],
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
[['user_id'], 'integer'],
[['user_id'], 'required'],
['user_id', 'unique', 'message' => 'Уже является менеджером'],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
@ -45,7 +45,7 @@ class Manager extends \yii\db\ActiveRecord
{
return [
'id' => 'ID',
'user_card_id' => 'Карточка менеджера',
'user_id' => 'Карточка менеджера',
];
}
@ -55,7 +55,7 @@ class Manager extends \yii\db\ActiveRecord
*/
public function beforeDelete()
{
foreach ($this->managerEmployees as $employee){
foreach ($this->managerEmployees as $employee) {
$employee->delete();
}
return parent::beforeDelete();
@ -64,9 +64,9 @@ class Manager extends \yii\db\ActiveRecord
/**
* @return ActiveQuery
*/
public function getUserCard()
public function getUser()
{
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
return $this->hasOne(User::class, ['id' => 'user_id']);
}
/**

View File

@ -9,7 +9,7 @@ use yii\db\ActiveQuery;
*
* @property int $id
* @property int $manager_id
* @property int $user_card_id
* @property int $employee_id
*
* @property Manager $manager
* @property UserCard $userCard
@ -30,10 +30,10 @@ class ManagerEmployee extends \yii\db\ActiveRecord
public function rules()
{
return [
[['manager_id', 'user_card_id'], 'required'],
[['manager_id', 'employee_id'], 'required'],
[['manager_id'], 'integer'],
['user_card_id', 'unique', 'targetAttribute' => ['manager_id', 'user_card_id'], 'message'=>'Этот сотрудник уже закреплён за менеджером'],
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
['employee_id', 'unique', 'targetAttribute' => ['manager_id', 'user_card_id'], 'message' => 'Этот сотрудник уже закреплён за менеджером'],
[['employee_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
[['manager_id'], 'exist', 'skipOnError' => true, 'targetClass' => Manager::className(), 'targetAttribute' => ['manager_id' => 'id']],
];
}
@ -46,16 +46,16 @@ class ManagerEmployee extends \yii\db\ActiveRecord
return [
'id' => 'ID',
'manager_id' => 'Менеджер',
'user_card_id' => 'Карточка работника',
'employee_id' => 'Карточка работника',
];
}
/**
* @return ActiveQuery
*/
public function getUserCard(): ActiveQuery
public function getEmployee()
{
return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']);
return $this->hasOne(User::class, ['id' => 'employee_id']);
}
/**

View File

@ -19,6 +19,7 @@ use yii\helpers\ArrayHelper;
* @property string $budget
* @property int $company_id
* @property int $hh_id
* @property int $owner_id
*
* @property FieldsValue[] $fieldsValues
* @property Company $company
@ -59,6 +60,7 @@ class Project extends \yii\db\ActiveRecord
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
[['name'], 'string', 'max' => 255],
[['budget'], 'string', 'max' => 100],
[['owner_id'], 'integer'],
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
[['hh_id'], 'exist', 'skipOnError' => true, 'targetClass' => Hh::class, 'targetAttribute' => ['hh_id' => 'id']],
];
@ -79,6 +81,7 @@ class Project extends \yii\db\ActiveRecord
'budget' => 'Бюджет',
'company_id' => 'Компания',
'hh_id' => 'Проект на hh.ru',
'owner_id' => 'Владелец проекта',
];
}
@ -98,6 +101,14 @@ class Project extends \yii\db\ActiveRecord
return $this->hasOne(Company::class, ['id' => 'company_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getOwner()
{
return $this->hasOne(User::class, ['id' => 'owner_id']);
}
/**
* @return \yii\db\ActiveQuery
*/

View File

@ -0,0 +1,95 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "project_column".
*
* @property int $id
* @property string $title
* @property int $project_id
* @property string $created_at
* @property string $updated_at
* @property int $status
*
* @property Project $project
*/
class ProjectColumn extends \yii\db\ActiveRecord
{
const STATUS_ACTIVE = 1;
const STATUS_DISABLE = 0;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'project_column';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['title', 'project_id'], 'required'],
[['project_id', 'status'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 255],
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'title' => 'Название',
'project_id' => 'Проект',
'created_at' => 'Дата создания',
'updated_at' => 'Дата редактирования',
'status' => 'Статус',
];
}
/**
* @return array[]
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
];
}
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::STATUS_ACTIVE => 'Активен',
self::STATUS_DISABLE => 'Выключен'
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}
}