M240507155532AddSystemMenu.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240507155532AddSystemMenu
  6. */
  7. class M240507155532AddSystemMenu extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $time = time();
  16. $sql = <<<SQL
  17. 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, 0, 'admin/expire-notice/index', 'el-icon-s-operation', 1, 0, 999, '[]', 'tr_0', 1, {$time}, {$time});
  18. SQL;
  19. $this->execute($sql);
  20. $id = $this->db->getLastInsertID($sql);
  21. $tree = 'tr_0 tr_' . $id;
  22. $sql2 = <<<SQL
  23. INSERT INTO `qimall_menu` (`title`, `app_id`, `cate_id`, `addons_name`, `is_addon`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `tree`, `status`, `created_at`, `updated_at`) VALUES ('过期提醒', 'backend', 1, '', 0, {$id}, 'admin/expire-notice/index', '', 1, 0, 999, '{$tree}', 1, {$time}, {$time});
  24. SQL;
  25. $this->execute($sql2);
  26. } catch (\Exception $e) {
  27. }
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function safeDown()
  33. {
  34. echo "M240507155532AddSystemMenu cannot be reverted.\n";
  35. return false;
  36. }
  37. }