1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\Permission;
- use app\model\Grant;
- class AddVrManagerMenuToPermission extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- *
- */
- public function change()
- {
- //智慧屏 数据表
- $menu = [
- 'pid' => 0,
- 'uri' => '',
- 'auth_name' => 'VR管理',
- 'is_menu' => 1,
- 'sort' => 50,
- 'relation' => '',
- 'icon'=>'layui-icon layui-icon-chart-screen'
- ];
- $pid = Permission::insertGetId($menu);
- $permission = new Permission();
- $child = $permission->saveAll([
- ['pid'=>$pid,'uri'=>'vrManage/floder_list','auth_name'=>'作品管理','is_menu'=>1,'sort'=>50,'relation'=>'vrManage/floder_list,vrManage/make_floder,vrManage/floder_child,vrManage/edit_floder,vrManage/del_floder,vrManage/group_check_list,vrManage/batch_mobile,vrManage/checking,vrManage/moveto_floder,vrManage/del_group,vrManage/switch'],
- ]);
- $ids = [(int)$pid];
- foreach ($child as $v) {
- $ids[] = (int)$v->id;
- }
- //先给志远装饰添加vr管理菜单
- $grant = Grant::find(28);
- $permission = array_merge(json_decode(json_encode($grant->permission), true), $ids);
- asort($permission);
- $grant->permission = $permission;
- $grant->save();
- }
- }
|