Updated validation for the project
This commit is contained in:
parent
e712f2fc36
commit
b004f6e21b
@ -23,6 +23,7 @@ use yii\helpers\ArrayHelper;
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property Company $company
|
||||
* @property User $owner
|
||||
* @property ProjectUser[] $projectUsers
|
||||
* @property Mark[] $mark
|
||||
* @property MarkEntity[] $markEntity
|
||||
@ -55,8 +56,8 @@ class Project extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['name', 'unique'],
|
||||
[['name', 'status'], 'required'],
|
||||
[['name', 'owner_id', 'status'], 'required'],
|
||||
[['owner_id', 'name'], 'unique', 'targetAttribute' => ['owner_id', 'name']],
|
||||
[['description'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
||||
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m231013_122324_add_foreign_key_in_project_from_owner_id_to_user_id
|
||||
*/
|
||||
class m231013_122324_add_foreign_key_in_project_from_owner_id_to_user_id extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addForeignKey(
|
||||
'project_user',
|
||||
'project',
|
||||
'owner_id',
|
||||
'user',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('project_user', 'project');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user