fix detach fail, marks

This commit is contained in:
2023-10-06 00:37:46 +03:00
parent 5cdd516696
commit 21b0135c68
11 changed files with 643 additions and 2 deletions

22
common/models/Entity.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace common\models;
class Entity
{
const ENTITY_TYPE_PROJECT = 1;
const ENTITY_TYPE_TASK = 2;
/**
* @return string[]
*/
public static function getEntityTypeList(): array
{
return [
self::ENTITY_TYPE_PROJECT => "Проект",
self::ENTITY_TYPE_TASK => "Задача",
];
}
}

View File

@ -9,6 +9,9 @@ use Yii;
*
* @property int $id
* @property string $title
* @property string $slug
* @property string $color
* @property int $status
*
* @property ProjectMark[] $projectMarks
*/
@ -28,7 +31,8 @@ class Mark extends \yii\db\ActiveRecord
public function rules()
{
return [
[['title'], 'string', 'max' => 255],
[['title', 'slug', 'color'], 'string', 'max' => 255],
[['status'], 'integer'],
];
}
@ -40,6 +44,9 @@ class Mark extends \yii\db\ActiveRecord
return [
'id' => 'ID',
'title' => 'Название',
'slug' => 'Ключ',
'color' => 'Цвет',
'status' => 'Статус',
];
}

View File

@ -0,0 +1,70 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "mark_entity".
*
* @property int $id
* @property int $mark_id
* @property int $entity_type
* @property int $entity_id
*/
class MarkEntity extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'mark_entity';
}
/**
* @return string[]
*/
public function fields(): array
{
return [
'id',
'mark_id',
'mark',
'entity_type',
'entity_id',
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['mark_id', 'entity_type', 'entity_id'], 'required'],
[['mark_id', 'entity_type', 'entity_id'], 'integer'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'mark_id' => 'Mark ID',
'entity_type' => 'Entity Type',
'entity_id' => 'Entity ID',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getMark(): \yii\db\ActiveQuery
{
return $this->hasOne(Mark::class, ['id' => 'mark_id']);
}
}

View File

@ -102,6 +102,7 @@ class ProjectTask extends ActiveRecord
return [
'id',
'project_id',
'project.name',
'title',
'created_at',
'updated_at',