cleans up the Unaccepted Asset reminder variables

This commit is contained in:
Godfrey M 2024-12-05 11:46:56 -08:00
parent 3f8916ea2e
commit 9d49b01958

View file

@ -68,16 +68,17 @@ class SendAcceptanceReminder extends Command
$no_mail_address = []; $no_mail_address = [];
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) { foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
//the [0] is weird, but it allows for the item_count to work and grabs the appropriate info for each user. collapsing and flattening the query doesn't work above.
$locale = $unacceptedAssetGroup[0]['acceptance']->assignedTo?->locale; $acceptance = $unacceptedAssetGroup[0]['acceptance'];
$email = $unacceptedAssetGroup[0]['acceptance']->assignedTo?->email; $locale = $acceptance->assignedTo?->locale;
$email = $acceptance->assignedTo?->email;
$item_count = $unacceptedAssetGroup->count(); $item_count = $unacceptedAssetGroup->count();
if ($locale && $email) { if ($locale && $email) {
Mail::to($email)->send((new UnacceptedAssetReminderMail($unacceptedAssetGroup[0]['acceptance'], $item_count))->locale($locale)); Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count))->locale($locale));
} elseif ($email) { } elseif ($email) {
Mail::to($email)->send((new UnacceptedAssetReminderMail($unacceptedAssetGroup[0]['acceptance'], $item_count))); Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count)));
} }
$count++; $count++;
} }