20220613092007_add_menu_prefancement_tasks.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Permission;
  5. use app\model\Grant;
  6. class AddMenuPrefancementTasks extends Migrator
  7. {
  8. /**
  9. * Change Method.
  10. *
  11. * Write your reversible migrations using this method.
  12. *
  13. * More information on writing migrations is available here:
  14. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  15. *
  16. * The following commands can be used in this method and Phinx will
  17. * automatically reverse them when rolling back:
  18. *
  19. * createTable
  20. * renameTable
  21. * addColumn
  22. * renameColumn
  23. * addIndex
  24. * addForeignKey
  25. *
  26. * Remember to call "create()" or "update()" and NOT "save()" when working
  27. * with the Table class.
  28. */
  29. public function change()
  30. {
  31. $menu = [
  32. 'pid' => 0,
  33. 'uri'=>'preformanceTasks/index',
  34. 'is_menu'=>1,
  35. 'icon'=>'layui-icon layui-icon-set-sm',
  36. 'sort'=>50,
  37. 'relation'=>'preformanceTasks/index,preformanceTasks/orders,preformanceTasks/tasks,preformance_tasks/add,preformanceTasks/add,preformanceTasks/add_data,preformanceTasks/assign,preformanceTasks/get_person,preformanceTasks/get_cid,preformanceTasks/save,preformanceTasks/edit,preformanceTasks/edit_data,preformanceTasks/deposit,preformanceTasks/deposit_list,preformanceTasks/money,preformanceTasks/details,preformanceTasks/details_list,preformanceTasks/statistical,preformanceTasks/statistical_list,dailyTasks/index,dailyTasks/index,dailyTasks/list,dailyTasks/person,dailyTasks/person_list,dailyTasks/del_task,dailyTasks/index,preformanceTasks/del_tasks',
  38. 'auth_name'=>'任务中心'
  39. ];
  40. $id = Permission::insertGetId($menu);
  41. $info = Grant::where('id',1)->find();
  42. $pids = (array)$info->permission;
  43. $pids[] = (int)$id;
  44. $info->permission = array_values($pids);
  45. $info->save();
  46. $info = Grant::where('id',28)->find();
  47. $pids = (array)$info->permission;
  48. $pids[] = (int)$id;
  49. $info->permission = array_values($pids);
  50. $info->save();
  51. }
  52. }