where(['cate_id' => 2, 'url' => 'mall/diy/index', 'pid' => 0, 'level' => 1, 'status' => 1]) ->asArray()->one(); if (empty($menu)) throw new \Exception('qimall_menu没有查询到数据'); $pid = $menu['id']; $tree = $menu['tree'] . ' tr_' . $pid; $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', 2, '', 0, $pid, 'mall/attachment/index', '', 2, 0, 999, NULL, '$tree', 1, 1689130872, 1689130872);"; $this->execute($sql); $auth_item = AuthItem::find()->where(['cate_id' => 2, 'name' => 'mall/diy/index', 'pid' => 0, 'level' => 1, 'status' => 1])->asArray()->one(); if (empty($auth_item)) throw new \Exception('qimall_rbac_auth_item没有查询到数据'); $pid = $auth_item['id']; $tree = $auth_item['tree'] . ' tr_' . $pid; $sql = "INSERT INTO `qimall_rbac_auth_item` ( `name`, `title`, `app_id`, `addons_name`, `pid`, `level`, `is_addon`, `sort`, `tree`, `status`, `created_at`, `updated_at`, `cate_id`) VALUES ( 'mall/attachment/index', '素材管理', 'backend', '', $pid, 2, 0, 999, '$tree', 1, 1689129562, 1689129585, 2);"; $this->execute($sql); echo '素材管理菜单插入成功' . PHP_EOL; } catch (\Exception $e) { echo '素材管理菜单插入失败:' . $e->getMessage() . PHP_EOL; } } /** * {@inheritdoc} */ public function safeDown() { echo "M231027025607InsertAttachmentQimallMenu cannot be reverted.\n"; return false; } /* // Use up()/down() to run migration code without a transaction. public function up() { } public function down() { echo "M231027025607InsertAttachmentQimallMenu cannot be reverted.\n"; return false; } */ }