From 49b3edac6ff90579c0aa9da88825ca423077c2b2 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 9 Dec 2025 10:53:15 -0800 Subject: [PATCH 1/3] gets asset assignments included for a user email all --- app/Notifications/CurrentInventory.php | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/app/Notifications/CurrentInventory.php b/app/Notifications/CurrentInventory.php index 170f183d946b..7c9531b9b9c7 100644 --- a/app/Notifications/CurrentInventory.php +++ b/app/Notifications/CurrentInventory.php @@ -39,12 +39,31 @@ public function via() * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail() - { + { $userAssets = $this->user->assets; + $userAccessories = $this->user->accessories; + $userLicenses = $this->user->licenses; + $assetsAssets = $userAssets->flatMap(fn ($asset) => $asset->assignedAssets); + $assetsAccessories = $userAssets->flatMap(fn ($asset) => $asset->assignedAccessories->map(fn ($checkout) => $checkout->accessory)->filter()); + $assetsLicenses = $userAssets->flatMap(fn ($asset) => $asset->licenses); + $assetsComponents = $userAssets->flatMap(fn ($asset) => $asset->components); + $allAssets = $userAssets + ->concat($assetsAssets) + ->unique() + ->values(); + $allLicenses = $userLicenses + ->concat($assetsLicenses) + ->unique() + ->values(); + $allAccessories = $userAccessories + ->concat($assetsAccessories) + ->unique() + ->values(); + $message = (new MailMessage)->markdown('notifications.markdown.user-inventory', [ - 'assets' => $this->user->assets, - 'accessories' => $this->user->accessories, - 'licenses' => $this->user->licenses, + 'assets' => $allAssets, + 'accessories' => $allAccessories, + 'licenses' => $allLicenses, 'consumables' => $this->user->consumables, ]) ->subject(trans('mail.inventory_report')) From 45440ae2774ee3d909de8c155d409fd0f00c033c Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 9 Dec 2025 17:35:20 -0800 Subject: [PATCH 2/3] adds components to markdown --- app/Notifications/CurrentInventory.php | 10 +++++++--- .../notifications/markdown/user-inventory.blade.php | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Notifications/CurrentInventory.php b/app/Notifications/CurrentInventory.php index 7c9531b9b9c7..19e9686cd061 100644 --- a/app/Notifications/CurrentInventory.php +++ b/app/Notifications/CurrentInventory.php @@ -39,24 +39,27 @@ public function via() * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail() - { $userAssets = $this->user->assets; + { + //assigned to user + $userAssets = $this->user->assets; $userAccessories = $this->user->accessories; $userLicenses = $this->user->licenses; + + //assigned through assets to user $assetsAssets = $userAssets->flatMap(fn ($asset) => $asset->assignedAssets); $assetsAccessories = $userAssets->flatMap(fn ($asset) => $asset->assignedAccessories->map(fn ($checkout) => $checkout->accessory)->filter()); $assetsLicenses = $userAssets->flatMap(fn ($asset) => $asset->licenses); $assetsComponents = $userAssets->flatMap(fn ($asset) => $asset->components); + $allAssets = $userAssets ->concat($assetsAssets) ->unique() ->values(); $allLicenses = $userLicenses ->concat($assetsLicenses) - ->unique() ->values(); $allAccessories = $userAccessories ->concat($assetsAccessories) - ->unique() ->values(); $message = (new MailMessage)->markdown('notifications.markdown.user-inventory', @@ -65,6 +68,7 @@ public function toMail() 'accessories' => $allAccessories, 'licenses' => $allLicenses, 'consumables' => $this->user->consumables, + 'components' => $assetsComponents, ]) ->subject(trans('mail.inventory_report')) ->withSymfonyMessage(function (Email $message) { diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index ec476cf0394a..e2eaff12449c 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -73,6 +73,18 @@ @endif +@if ($components->count() > 0) +## {{ $components->count() }} {{ trans('general.component') }} + + +@foreach($components as $component) + + + +@endforeach +
{{ trans('mail.name') }}
{{ $component->name }}
+@endif + @endcomponent From c2e711bcaea2025cd21a89a38b18099c9477b38b Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 9 Dec 2025 18:14:33 -0800 Subject: [PATCH 3/3] change component translation to plural --- resources/views/notifications/markdown/user-inventory.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/notifications/markdown/user-inventory.blade.php b/resources/views/notifications/markdown/user-inventory.blade.php index e2eaff12449c..915027085add 100644 --- a/resources/views/notifications/markdown/user-inventory.blade.php +++ b/resources/views/notifications/markdown/user-inventory.blade.php @@ -74,7 +74,7 @@ @endif @if ($components->count() > 0) -## {{ $components->count() }} {{ trans('general.component') }} +## {{ $components->count() }} {{ trans('general.components') }} @foreach($components as $component)
{{ trans('mail.name') }}