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 = [];
foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {
$locale = $unacceptedAssetGroup[0]['acceptance']->assignedTo?->locale;
$email = $unacceptedAssetGroup[0]['acceptance']->assignedTo?->email;
//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.
$acceptance = $unacceptedAssetGroup[0]['acceptance'];
$locale = $acceptance->assignedTo?->locale;
$email = $acceptance->assignedTo?->email;
$item_count = $unacceptedAssetGroup->count();
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) {
Mail::to($email)->send((new UnacceptedAssetReminderMail($unacceptedAssetGroup[0]['acceptance'], $item_count)));
Mail::to($email)->send((new UnacceptedAssetReminderMail($acceptance, $item_count)));
}
$count++;
}