Zhouzhendong před 5 roky
rodič
revize
132fd9a7f9
1 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 6 4
      app/Services/AuthorityService.php

+ 6 - 4
app/Services/AuthorityService.php

@@ -90,8 +90,10 @@ class AuthorityService
 
         foreach ($authorities as $authority){
             if ($authority->parent_id){
-                if (isset($authMap[$authority->parent_id]))$authMap[$authority->parent_id]["child"][] = $authMap[$authority->id];
-                else $authMap = $this->formatAuthority($authMap,$authMap[$authority->id]);
+                if (!isset($authMap[$authority->parent_id])){
+                    $authTem = $this->formatAuthority($authMap,$authMap[$authority->id]);
+                    if ($authTem)$authMap = $authTem;
+                } else $authMap[$authority->parent_id]["child"][] = $authMap[$authority->id];
                 unset($authMap[$authority->id]);
             }
         }
@@ -105,7 +107,7 @@ class AuthorityService
      * @param array $authMap
      * @param array $authorities
      *
-     * @return array
+     * @return array|bool
      */
     private function formatAuthority(array $authMap,array $authorities)
     {
@@ -124,6 +126,6 @@ class AuthorityService
                 }
             }
         }
-        return $authMap;
+        return false;
     }
 }