A free open source IT asset/license management system
Added counts to API
snipe4839181beb92
diff --git a/app/Http/Controllers/Api/DepreciationsController.php b/app/Http/Controllers/Api/DepreciationsController.phpindex 0209eae392..72e0f3a14a 100644--- a/app/Http/Controllers/Api/DepreciationsController.php+++ b/app/Http/Controllers/Api/DepreciationsController.php@@ -20,9 +20,22 @@ class DepreciationsController extends Controllerpublic function index(Request $request) : JsonResponse | array{$this->authorize('view', Depreciation::class);- $allowed_columns = ['id','name','months','depreciation_min', 'depreciation_type','created_at'];-- $depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','user_id','created_at','updated_at');+ $allowed_columns = [+ 'id',+ 'name',+ 'months',+ 'depreciation_min',+ 'depreciation_type',+ 'created_at',+ 'assets_count',+ 'models_count',+ 'licenses_count',+ ];++ $depreciations = Depreciation::select('id','name','months','depreciation_min','depreciation_type','user_id','created_at','updated_at')+ ->withCount('assets as assets_count')+ ->withCount('models as models_count')+ ->withCount('licenses as licenses_count');if ($request->filled('search')) {$depreciations = $depreciations->TextSearch($request->input('search'));