A free open source IT asset/license management system
update profile Controller print inventory
Godfrey M516771d94842
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.phpindex 712644d953..81afbea8b1 100755--- a/app/Http/Controllers/ProfileController.php+++ b/app/Http/Controllers/ProfileController.php@@ -210,14 +210,59 @@ class ProfileController extends Controller*/public function printInventory() : View{- $show_users = User::where('id',auth()->user()->id)->get();-- return view('users/print')- ->with('assets', auth()->user()->assets())- ->with('licenses', auth()->user()->licenses()->get())- ->with('accessories', auth()->user()->accessories()->get())- ->with('consumables', auth()->user()->consumables()->get())- ->with('users', $show_users)+ $userId = auth()->id();++ $show_user = User::where('id', $userId)+ ->with([+ 'assets.log' => fn ($query) => $query->withTrashed()+ ->where('target_type', User::class)+ ->where('target_id', $userId)+ ->where('action_type', 'accepted'),++ 'assets.assignedAssets.log' => fn ($query) => $query->withTrashed()+ ->where('target_type', User::class)+ ->where('target_id', $userId)+ ->where('action_type', 'accepted'),++ 'assets.assignedAssets.defaultLoc',+ 'assets.assignedAssets.location',+ 'assets.assignedAssets.model.category',+ 'assets.components',+ 'assets.assignedAccessories',+ 'assets.defaultLoc',+ 'assets.location',+ 'assets.licenses',+ 'assets.model.category',++ 'accessories.log' => fn ($query) => $query->withTrashed()+ ->where('target_type', User::class)+ ->where('target_id', $userId)+ ->where('action_type', 'accepted'),++ 'accessories.category',+ 'accessories.manufacturer',++ 'consumables.log' => fn ($query) => $query->withTrashed()+ ->where('target_type', User::class)+ ->where('target_id', $userId)+ ->where('action_type', 'accepted'),++ 'consumables.category',+ 'consumables.manufacturer',+ 'licenses.category',+ ])+ ->withTrashed()+ ->firstOrFail();++ $indirectItemsCount =+ $show_user->assets->flatMap->assignedAssets->count()+ + $show_user->assets->flatMap->components->count()+ + $show_user->assets->flatMap->licenses->count()+ + $show_user->assets->flatMap->assignedAccessories->count();++ return view('users.print')+ ->with('users', [$show_user])+ ->with('indirectItemsCount', $indirectItemsCount)->with('settings', Setting::getSettings());}