Browse Source

资产列表页面容器库和容器可通过资产来显示

kely 7 months ago
parent
commit
de10bdf26a
1 changed files with 4 additions and 4 deletions
  1. 4 4
      app/Http/Controllers/API/ContainerController.php

+ 4 - 4
app/Http/Controllers/API/ContainerController.php

@@ -262,12 +262,12 @@ class ContainerController extends Controller
         $librarys=Library::query()->where('company_id',$companyId)->withCount('container') ->get(['id', 'name', 'created_at', 'updated_at', 'container_count as container_count']);
         $libraryCount=$librarys->count();
         $containerCount = $librarys->sum('container_count');
-        $libraryType = $request->type;
 
         $MyLibrarys=Library::query()->allowed()->filter($request->all())->orderBy('updated_at', 'desc')->get(['id', 'name', 'type','created_at', 'updated_at']);
-        $MyContainers = Container::query()->allowed()->when($libraryType,function ($query) use ($libraryType){
-            $query->whereHas('library', function ($query) use ($libraryType) {
-                $query->where('type', $libraryType);
+        $MyContainers = Container::query()->allowed()->when($request,function ($query) use ($request){
+            $query->whereHas('library', function ($query) use ($request) {
+                $query->where('type', $request->type)
+                ->where('asset_id',$request->asset);
             });
         })->orderBy('updated_at', 'desc')->get( ['id', 'name','library_id', 'created_at', 'updated_at']);