M240914091100InsertOrderLogAndUserLogMenu.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\migrations;
  3. use common\models\backend\Menu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240914091100InsertOrderLogAndUserLogMenu
  7. */
  8. class M240914091100InsertOrderLogAndUserLogMenu 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/logs',
  22. 'icon' => '',
  23. // 子菜单权限,此参数若为空则表示无需增加子菜单权限)
  24. 'authItemChild' => []
  25. ],
  26. [
  27. 'cate_id' => '2',// 类型[1=平台,2=商城]
  28. 'pid' => '',
  29. 'title' => '会员记录',
  30. 'route' => 'mall/logs/user',
  31. 'icon' => '',
  32. 'p_route' => 'mall/logs',
  33. // 子菜单权限,此参数若为空则表示无需增加子菜单权限)
  34. 'authItemChild' => []
  35. ],
  36. [
  37. 'cate_id' => '2',// 类型[1=平台,2=商城]
  38. 'pid' => '33',
  39. 'title' => '订单日志',
  40. 'route' => 'mall/logs/order',
  41. 'icon' => '',
  42. // 子菜单权限,此参数若为空则表示无需增加子菜单权限)
  43. 'authItemChild' => []
  44. ],
  45. ];
  46. $res = Menu::migrateCreateMenu($data);
  47. if ($res === false) throw new \Exception(Menu::getStaticError());
  48. } catch (\Exception $e) {
  49. \Yii::error('迁移错误:' . $e->getMessage());
  50. }
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function safeDown()
  56. {
  57. return false;
  58. }
  59. /*
  60. // Use up()/down() to run migration code without a transaction.
  61. public function up()
  62. {
  63. }
  64. public function down()
  65. {
  66. echo "M240914091100InsertOrderLogAndUserLogMenu cannot be reverted.\n";
  67. return false;
  68. }
  69. */
  70. }