M240313084103SecondaryCard.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use addons\Store\common\models\StoreMenu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240313084103SecondaryCard
  7. */
  8. class M240313084103SecondaryCard extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $sql = "INSERT INTO `qimall_addons_store_addons` (`title`, `name`, `cover`, `brief_introduction`, `status`, `created_at`, `updated_at`) VALUES ('次卡', 'SecondaryCard', '', '次卡', '1', '1702975895', '1702975895');";
  16. $this->execute($sql);
  17. $sql = "INSERT INTO `qimall_addons_store_menu` (`title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ( '次卡列表', '0', '0', 'store/secondary-card/default/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'SecondaryCard', '1');";
  18. $this->execute($sql);
  19. $model = StoreMenu::find()->where(['title'=>'次卡列表','addons_name'=>'SecondaryCard'])->orderBy('id asc')->one();
  20. $pid = $model['id'];
  21. $sql = "INSERT INTO `qimall_addons_store_menu` (`title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ( '次卡列表', '0', '{$pid}', 'store/secondary-card/default/index', '', '2', '0', '999', NULL, '', '1', '0', '0', 'SecondaryCard', '1');
  22. INSERT INTO `qimall_addons_store_menu` (`title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ( '开卡记录', '0', '{$pid}', 'store/secondary-card/default/order', '', '2', '0', '999', NULL, '', '1', '0', '0', 'SecondaryCard', '1');
  23. INSERT INTO `qimall_addons_store_menu` ( `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ( '使用记录', '0', '{$pid}', 'store/secondary-card/default/use-log', '', '2', '0', '999', NULL, '', '1', '0', '0', 'SecondaryCard', '1');";
  24. $this->execute($sql);
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function safeDown()
  30. {
  31. echo "M240313084103SecondaryCard cannot be reverted.\n";
  32. return false;
  33. }
  34. /*
  35. // Use up()/down() to run migration code without a transaction.
  36. public function up()
  37. {
  38. }
  39. public function down()
  40. {
  41. echo "M240313084103SecondaryCard cannot be reverted.\n";
  42. return false;
  43. }
  44. */
  45. }