|
|
@@ -188,6 +188,21 @@ class TestController extends Controller
|
|
|
|
|
|
public function zzd()
|
|
|
{
|
|
|
+ $aa = [];
|
|
|
+ $authorities = Authority::query()->where("name","like","订单管理%")->orWhere("name","like","运输管理%")->get();
|
|
|
+ //Auth::user()->authorities();
|
|
|
+ foreach ($authorities as $authority){
|
|
|
+ $item = $authority->toArray();
|
|
|
+ $item["child"] = [];
|
|
|
+ $aa[$authority->id] = $item;
|
|
|
+ }
|
|
|
+ foreach ($authorities as $authority){
|
|
|
+ if ($authority->id_parent){
|
|
|
+ if (isset($aa[$authority->id_parent]))$aa[$authority->id_parent]["child"][] = $aa[$authority->id];
|
|
|
+ else $aa = $this->tttt($aa,$aa[$authority->id]);
|
|
|
+ unset($aa[$authority->id]);
|
|
|
+ }
|
|
|
+ }
|
|
|
$ser = new MenuService();
|
|
|
Cache::flush();
|
|
|
$menus = $ser->getMenu();
|
|
|
@@ -203,24 +218,50 @@ class TestController extends Controller
|
|
|
unset($result[$menu->id]);
|
|
|
}
|
|
|
}
|
|
|
+ $result = $this->ttt1(array_values($result),$aa);
|
|
|
dd($result);
|
|
|
- $menus = [
|
|
|
- "A管理" => [
|
|
|
- "A二级" => [
|
|
|
- "A三级"
|
|
|
- ]
|
|
|
- ],
|
|
|
- "B管理" => []
|
|
|
- ];
|
|
|
- /*$authorities = [
|
|
|
- "A管理"=>[
|
|
|
- "A二级"=>[9
|
|
|
- "A三级"=>[
|
|
|
- "A四级"
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]
|
|
|
- ];*/
|
|
|
+ }
|
|
|
+ function ttt1($result,$authority){
|
|
|
+ foreach ($result as $index=>$item){
|
|
|
+ $mark = false;
|
|
|
+ foreach ($authority as $j=>$a){
|
|
|
+ if ($item["name"] == $a["name"]){
|
|
|
+ $mark = true;
|
|
|
+ $result[$index]["authority"] = $j;
|
|
|
+ $authority[$j]["mark"] = true;
|
|
|
+ if ($a["child"])$result[$index]["child"] = $this->ttt1($item["child"],$a["child"]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!$mark)unset($result[$index]);
|
|
|
+ }
|
|
|
+ foreach ($authority as $a){
|
|
|
+ if (!isset($a["mark"])){
|
|
|
+ $result[] = [
|
|
|
+ "name" => $a["name"],
|
|
|
+ "route" => "",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+ function tttt(array $aa,$item)
|
|
|
+ {
|
|
|
+ foreach ($aa as $index=>$data){
|
|
|
+ if ($data["id"]==$item["id_parent"]){
|
|
|
+ $aa[$index]["child"][] = $item;
|
|
|
+ unset($aa[$item["id"]]);
|
|
|
+ return $aa;
|
|
|
+ }else{
|
|
|
+ if ($aa[$index]["child"]){
|
|
|
+ $re = $this->tttt($aa[$index]["child"],$item);
|
|
|
+ if ($re){
|
|
|
+ $aa[$index]["child"] = $re;
|
|
|
+ return $aa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
public function updateLaborRemark()
|