| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\migrations;
- use common\models\backend\Menu;
- use yii\db\Migration;
- /**
- * Class M250325020133InsertQimallMenu
- */
- class M250325020133InsertQimallMenu extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- // $qimall_menu = Menu::find()->where(['title' => '系统管理', 'cate_id' => 1, 'is_addon' => 0, 'pid' => 0])->asArray()->one();
- // $sql = "INSERT INTO `qimall_menu`(`title`, `app_id`, `cate_id`, `addons_name`, `is_addon`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`) VALUES ('备份管理', 'backend', 1, '', 0, ".$qimall_menu['id'].", 'admin/expire-notice/backups', '', 1, 0, 999, NULL, '', 1, 0, 0);";
- // $this->execute($sql);
- $sql = "select * from qimall_menu where title='系统管理' and cate_id = 1 and is_addon = 0 and pid = 0";
- $list = \Yii::$app->db->createCommand($sql)->queryAll();
- $data = [
- [
- 'cate_id' => '1',// 类型[1=平台,2=商城]
- 'pid' => $list[0]['id'],
- 'title' => '备份管理',
- 'route' => 'admin/expire-notice/backups',
- 'icon' => '',
- 'authItemChild' => [// 子菜单权限,此参数若为空则表示无需增加子菜单权限)
- [
- 'title' => '备份当前',
- 'name' => 'admin/expire-notice/start-backups',
- ],
- [
- 'title' => '下载',
- 'name' => 'admin/expire-notice/down',
- ],
- [
- 'title' => '删除',
- 'name' => 'admin/expire-notice/delete',
- ],
- ]
- ]
- ];
- $res = Menu::migrateCreateMenu($data);
- if ($res === false) throw new \Exception(Menu::getStaticError());
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M250325020133InsertQimallMenu cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M250325020133InsertQimallMenu cannot be reverted.\n";
- return false;
- }
- */
- }
|