|  |  | <?php | 
|  |  | namespace App\Mail\lib; | 
|  |  | namespace Helper\Mail; | 
|  |  |  | 
|  |  |  | 
|  |  | use Illuminate\Support\Facades\Storage; | 
|  |  | use PHPMailer\PHPMailer\PHPMailer; | 
|  |  | use PHPMailer\PHPMailer\SMTP; | 
|  |  |  | 
| ... | ... | @@ -12,43 +14,6 @@ use PHPMailer\PHPMailer\SMTP; | 
|  |  | */ | 
|  |  | class MailFun { | 
|  |  |  | 
|  |  | /** | 
|  |  | * 列表 转 树数据 | 
|  |  | * @param $list | 
|  |  | * @param string $pk | 
|  |  | * @param string $pid | 
|  |  | * @param string $child | 
|  |  | * @param int $root | 
|  |  | * @param bool $empty_child | 
|  |  | * @return array | 
|  |  | * @time 2022/8/1 16:05 | 
|  |  | */ | 
|  |  | public static function list2Tree($list, $pk='id',$pid = 'pid',$child = '_child',$root=0, $empty_child=true) { | 
|  |  | // 创建Tree | 
|  |  | $tree = array(); | 
|  |  | if(is_array($list)) { | 
|  |  | // 创建基于主键的数组引用 | 
|  |  | $refer = array(); | 
|  |  | foreach ($list as $key => $data) { | 
|  |  | if($empty_child){ | 
|  |  | $list[$key][$child] =   []; | 
|  |  | } | 
|  |  | $refer[$data[$pk]] = &$list[$key]; | 
|  |  | } | 
|  |  | foreach ($list as $key => $data) { | 
|  |  | // 判断是否存在parent | 
|  |  | $parentId = $data[$pid]; | 
|  |  | if ($root == $parentId) { | 
|  |  | $tree[] = &$list[$key]; | 
|  |  | }else{ | 
|  |  | if (isset($refer[$parentId])) { | 
|  |  | $refer[$parentId][$child][] =   &$list[$key]; | 
|  |  | } | 
|  |  | } | 
|  |  | } | 
|  |  | } | 
|  |  | return $tree; | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * json encode | 
... | ... |  |