-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUnInstall.php
47 lines (43 loc) · 1.2 KB
/
UnInstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace addons\Merchants;
use yii\db\Migration;
use common\enums\AppEnum;
use common\models\common\AuthItemChild;
use common\models\common\AuthRole;
use common\models\common\ConfigValue;
use common\models\merchant\Member;
use common\models\merchant\Merchant;
use common\helpers\MigrateHelper;
use common\interfaces\AddonWidget;
/**
* 卸载
*
* Class UnInstall
* @package addons\Merchants
*/
class UnInstall extends Migration implements AddonWidget
{
/**
* @param $addon
* @return mixed|void
* @throws \yii\base\InvalidConfigException
* @throws \yii\web\NotFoundHttpException
* @throws \yii\web\UnprocessableEntityHttpException
*/
public function run($addon)
{
// 移除商家角色
AuthRole::deleteAll(['>', 'merchant_id', 1]);
// 移除商家权限
AuthItemChild::deleteAll(['app_id' => AppEnum::MERCHANT]);
// 清理商家
Merchant::deleteAll(['>', 'id', 1]);
// 清理商家所属用户
Member::deleteAll();
// 清理配置
ConfigValue::deleteAll(['>', 'merchant_id', 1]);
// MigrateHelper::downByPath([
// '@addons/Merchants/console/migrations/'
// ]);
}
}