M230713150123InsertQimallMenu.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\migrations;
  3. use common\models\backend\Menu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M230713150123InsertQimallMenu
  7. */
  8. class M230713150123InsertQimallMenu extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $data = [
  17. [
  18. 'cate_id' => '2',// 类型[1=平台,2=商城]
  19. 'pid' => '38',
  20. 'title' => '协议设置',
  21. 'route' => 'mall/service-agreement/index',
  22. 'icon' => '',
  23. 'authItemChild' => [// 子菜单权限,此参数若为空则表示无需增加子菜单权限)
  24. [
  25. 'title' => '添加/编辑协议',
  26. 'name' => 'mall/service-agreement/edit',
  27. ],
  28. [
  29. 'title' => '删除协议',
  30. 'name' => 'mall/service-agreement/del',
  31. ],
  32. ]
  33. ]
  34. ];
  35. $res = Menu::migrateCreateMenu($data);
  36. if ($res === false) throw new \Exception(Menu::getStaticError());
  37. }catch (\Exception $e){
  38. \Yii::error('迁移错误:' . $e->getMessage());
  39. }
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function safeDown()
  45. {
  46. echo "M230713150123InsertQimallMenu cannot be reverted.\n";
  47. return false;
  48. }
  49. /*
  50. // Use up()/down() to run migration code without a transaction.
  51. public function up()
  52. {
  53. }
  54. public function down()
  55. {
  56. echo "M230713150123InsertQimallMenu cannot be reverted.\n";
  57. return false;
  58. }
  59. */
  60. }