add company-manager role
This commit is contained in:
@ -35,6 +35,20 @@ class RbacController extends Controller
|
||||
$auth->assign($admin, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add company manager role
|
||||
*/
|
||||
public function actionCreateCompanyManagerRole()
|
||||
{
|
||||
$auth = Yii::$app->getAuthManager();
|
||||
|
||||
$role = $auth->createRole('company_manager');
|
||||
$role->description = 'Менеджер компании контр агента';
|
||||
$auth->add($role);
|
||||
|
||||
$this->stdout('Done!' . PHP_EOL);
|
||||
}
|
||||
|
||||
public function actionCreateEditor()
|
||||
{
|
||||
$auth = Yii::$app->authManager;
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m221128_114458_make_nullable_company_id_contractor_company_id_manager_id_columns_in_document_table
|
||||
*/
|
||||
class m221128_114458_make_nullable_company_id_contractor_company_id_manager_id_columns_in_document_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->alterColumn('document', 'company_id', $this->integer(11)->null());
|
||||
$this->alterColumn('document', 'contractor_company_id', $this->integer(11)->null());
|
||||
$this->alterColumn('document', 'manager_id', $this->integer(11)->null());
|
||||
$this->alterColumn('document', 'contractor_manager_id', $this->integer(11)->null());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->alterColumn('document', 'company_id', $this->integer(11)->notNull());
|
||||
$this->alterColumn('document', 'contractor_company_id', $this->integer(11)->notNull());
|
||||
$this->alterColumn('document', 'manager_id', $this->integer(11)->notNull());
|
||||
$this->alterColumn('document', 'contractor_manager_id', $this->integer(11)->notNull());
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m221128_114458_make_nullable_company_id_contractor_company_id_manager_id_columns_in_document_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{{%company_manager}}`.
|
||||
*/
|
||||
class m221129_100558_create_company_manager_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->createTable('{{%company_manager}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'company_id' => $this->integer(),
|
||||
'user_card_id' => $this->integer(),
|
||||
]);
|
||||
$this->addForeignKey('company_company_manager', 'company_manager', 'company_id', 'company', 'id');
|
||||
$this->addForeignKey('user_card_company_manager', 'company_manager', 'user_card_id', 'user_card', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('company_company_manager', 'company_manager');
|
||||
$this->dropForeignKey('user_card_company_manager', 'company_manager');
|
||||
$this->dropTable('{{%company_manager}}');
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m221130_090104_change_keys_in_document_table_from_manager_to_company_manager
|
||||
*/
|
||||
class m221130_090104_change_keys_in_document_table_from_manager_to_company_manager extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropForeignKey('manager_document', 'document');
|
||||
$this->dropForeignKey('contractor_manager_document', 'document');
|
||||
|
||||
$this->addForeignKey('company_manager_document', 'document', 'manager_id', 'company_manager', 'id');
|
||||
$this->addForeignKey('contractor_company_manager_document', 'document', 'contractor_manager_id', 'company_manager', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('company_manager_document', 'document');
|
||||
$this->dropForeignKey('contractor_company_manager_document', 'document');
|
||||
|
||||
$this->addForeignKey('manager_document', 'document', 'manager_id','manager', 'id');
|
||||
$this->addForeignKey('contractor_manager_document', 'document', 'contractor_manager_id','manager', 'id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m221130_090104_change_keys_in_document_table_from_manager_to_company_manager cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
Reference in New Issue
Block a user