fixed asset checkout markdown, and notifiable variable

This commit is contained in:
Godfrey M 2024-10-16 16:46:52 -07:00
parent 02bda3cd95
commit a7754c1a7f
2 changed files with 67 additions and 96 deletions

View file

@ -16,10 +16,9 @@ use App\Models\CheckoutAcceptance;
use App\Models\Component;
use App\Models\Consumable;
use App\Models\LicenseSeat;
use App\Models\Recipients\AdminRecipient;
use App\Models\Setting;
use App\Models\User;
use App\Notifications\CheckinAccessoryNotification;
use App\Notifications\CheckinAssetNotification;
use App\Notifications\CheckinLicenseSeatNotification;
use App\Notifications\CheckoutAccessoryNotification;
use App\Notifications\CheckoutAssetNotification;
@ -51,7 +50,7 @@ class CheckoutableListener
* Make a checkout acceptance and attach it in the notification
*/
$acceptance = $this->getCheckoutAcceptance($event);
$notifiable = $this->getNotifiable($event);
$notifiable = $event->checkedOutTo;
$mailable = $this->getCheckoutMailType($event, $acceptance);
// Send email notifications
try {
@ -99,7 +98,7 @@ class CheckoutableListener
}
}
$notifiable = $this->getNotifiable($event);
$notifiable = $event->checkedInBy;
$mailable = $this->getCheckinMailType($event);
// Send email notifications
@ -144,34 +143,6 @@ class CheckoutableListener
return $acceptance;
}
/**
* Gets the entities to be notified of the passed event
*
* @param Event $event
* @return Collection
*/
private function getNotifiable($event)
{
$notifiable = collect();
/**
* Notify who checked out the item as long as the model can route notifications
*/
if (method_exists($event->checkedOutTo, 'routeNotificationFor')) {
$notifiable->push($event->checkedOutTo);
}
/**
* Notify Admin users if the settings is activated
*/
if ((Setting::getSettings()) && (Setting::getSettings()->admin_cc_email != '')) {
$adminRecipient= new AdminRecipient;
$notifiable->push($adminRecipient->getEmail());
}
return new $notifiable;
}
/**
* Get the appropriate notification for the event
*