value('id'); if ($pid) { $data1 = [ 'pid'=> $pid, 'auth_name'=> '在施工地', 'uri'=> 'smartScreenMore/construction', 'is_menu'=> 1, 'sort'=> 60, 'relation'=> 'smartScreenMore/construction,smartScreenMore/construction_add,smartScreenMore/construction_edit,smartScreenMore/construction_delete,smartScreenMore/importLog' ]; $data2 = [ 'pid'=> $pid, 'auth_name'=> '项目清单', 'uri'=> 'smartScreenMore/project', 'is_menu'=> 1, 'sort'=> 61, 'relation'=> 'smartScreenMore/project,smartScreenMore/project_add,smartScreenMore/project_edit,smartScreenMore/project_delete,smartScreenMore/importLog' ]; $id1 = Permission::insertGetId($data1); $id2 = Permission::insertGetId($data2); $grant = Grant::find(1); $permission = array_merge(json_decode(json_encode($grant->permission), true), [$id1, $id2]); asort($permission); $grant->permission = $permission; $grant->save(); } } }