|
@@ -256,15 +256,20 @@ class ContainerController extends Controller
|
|
return $this->noContent();
|
|
return $this->noContent();
|
|
|
|
|
|
}
|
|
}
|
|
- public function containerReport(){
|
|
|
|
|
|
+ public function containerReport(Request $request){
|
|
|
|
|
|
$companyId=Auth::user()->company_id;
|
|
$companyId=Auth::user()->company_id;
|
|
$librarys=Library::query()->where('company_id',$companyId)->withCount('container') ->get(['id', 'name', 'created_at', 'updated_at', 'container_count as container_count']);
|
|
$librarys=Library::query()->where('company_id',$companyId)->withCount('container') ->get(['id', 'name', 'created_at', 'updated_at', 'container_count as container_count']);
|
|
$libraryCount=$librarys->count();
|
|
$libraryCount=$librarys->count();
|
|
$containerCount = $librarys->sum('container_count');
|
|
$containerCount = $librarys->sum('container_count');
|
|
-
|
|
|
|
- $MyLibrarys=Library::query()->allowed()->orderBy('updated_at', 'desc')->get(['id', 'name', 'type','created_at', 'updated_at']);
|
|
|
|
- $MyContainers = Container::query()->allowed()->orderBy('updated_at', 'desc')->get( ['id', 'name','library_id', 'created_at', 'updated_at']);
|
|
|
|
|
|
+ $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);
|
|
|
|
+ });
|
|
|
|
+ })->orderBy('updated_at', 'desc')->get( ['id', 'name','library_id', 'created_at', 'updated_at']);
|
|
|
|
|
|
return $this->success([
|
|
return $this->success([
|
|
'data' =>[
|
|
'data' =>[
|