Просмотр исходного кода

权限:货主关联权限增加联动子项删除

Zhouzhendong 5 лет назад
Родитель
Сommit
a00c05f8d8
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      app/Services/OwnerService.php

+ 5 - 2
app/Services/OwnerService.php

@@ -355,8 +355,11 @@ sql
      */
     public function deleteAuthority($owner)
     {
-        Authority::query()->where('name',"_{$owner['id']}")
+        $authorities = Authority::query()->where('name',"_{$owner['id']}")
             ->where("alias_name","like","(货主%")
-            ->delete();
+            ->get(["id"]);
+        $ids = array_column($authorities->toArray(),"id");
+        DB::table("authority_role")->whereIn("id_authority",$ids)->delete();
+        Authority::destroy($ids);
     }
 }