M241105024757CreateRefundStatisticsMenu.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\migrations;
  3. use common\models\backend\Menu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M241105024757CreateRefundStatisticsMenu
  7. */
  8. class M241105024757CreateRefundStatisticsMenu 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' => '36',
  20. 'title' => '售后数据',
  21. 'route' => 'mall/statistics/all-pay-type-refund',
  22. 'icon' => '',
  23. // 子菜单权限,此参数若为空则表示无需增加子菜单权限)
  24. 'authItemChild' => []
  25. ]
  26. ];
  27. $res = Menu::migrateCreateMenu($data);
  28. if ($res === false) throw new \Exception(Menu::getStaticError());
  29. } catch (\Exception $e) {
  30. \Yii::error('迁移错误:' . $e->getMessage());
  31. }
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function safeDown()
  37. {
  38. return false;
  39. }
  40. /*
  41. // Use up()/down() to run migration code without a transaction.
  42. public function up()
  43. {
  44. }
  45. public function down()
  46. {
  47. echo "M241105024757CreateRefundStatisticsMenu cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }