A free open source IT asset/license management system
Cleanup checkin notification constructors
Till Deeke4a71542f233b
diff --git a/app/Notifications/CheckinAccessoryNotification.php b/app/Notifications/CheckinAccessoryNotification.phpindex 052279892e..ee3bcac6ab 100644--- a/app/Notifications/CheckinAccessoryNotification.php+++ b/app/Notifications/CheckinAccessoryNotification.php@@ -2,6 +2,7 @@namespace App\Notifications;+use App\Models\Accessory;use App\Models\Setting;use App\Models\SnipeModel;use App\Models\User;@@ -15,31 +16,19 @@ use Illuminate\Support\Facades\Mail;class CheckinAccessoryNotification extends Notification{use Queueable;- /**- * @var- */- private $params;/*** Create a new notification instance.** @param $params*/- public function __construct($params)+ public function __construct(Accessory $accessory, $checkedOutTo, User $checkedInby, $note){- $this->target = $params['target'];- $this->item = $params['item'];- $this->admin = $params['admin'];- $this->note = '';- $this->target_type = $params['target'];- $this->settings = $params['settings'];-- if (array_key_exists('note', $params)) {- $this->note = $params['note'];- }---+ $this->item = $accessory;+ $this->target = $checkedOutTo;+ $this->admin = $checkedInby;+ $this->note = $note;+ $this->settings = Setting::getSettings();}/**diff --git a/app/Notifications/CheckinAssetNotification.php b/app/Notifications/CheckinAssetNotification.phpindex 78f3f00664..4053f22ffc 100644--- a/app/Notifications/CheckinAssetNotification.php+++ b/app/Notifications/CheckinAssetNotification.php@@ -2,13 +2,14 @@namespace App\Notifications;+use App\Models\Asset;use App\Models\Setting;-use Illuminate\Bus\Queueable;use App\Models\User;-use Illuminate\Notifications\Notification;+use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Notifications\Messages\MailMessage;use Illuminate\Notifications\Messages\SlackMessage;+use Illuminate\Notifications\Notification;class CheckinAssetNotification extends Notification{@@ -20,19 +21,15 @@ class CheckinAssetNotification extends Notification** @param $params*/- public function __construct($params)+ public function __construct(Asset $asset, $checkedOutTo, User $checkedInBy, $note){- $this->target = $params['target'];- $this->item = $params['item'];- $this->admin = $params['admin'];- $this->note = '';- $this->expected_checkin = '';- $this->target_type = $params['target_type'];- $this->settings = $params['settings'];+ $this->target = $checkedOutTo;+ $this->item = $asset;+ $this->admin = $checkedInBy;+ $this->note = $note;- if (array_key_exists('note', $params)) {- $this->note = $params['note'];- }+ $this->settings = Setting::getSettings();+ $this->expected_checkin = '';if ($this->item->expected_checkin) {$this->expected_checkin = \App\Helpers\Helper::getFormattedDateObject($this->item->expected_checkin, 'date',diff --git a/app/Notifications/CheckinLicenseNotification.php b/app/Notifications/CheckinLicenseNotification.phpindex f8a52ccf3c..3ff06d2ca3 100644--- a/app/Notifications/CheckinLicenseNotification.php+++ b/app/Notifications/CheckinLicenseNotification.php@@ -2,6 +2,7 @@namespace App\Notifications;+use App\Models\License;use App\Models\Setting;use App\Models\SnipeModel;use App\Models\User;@@ -25,19 +26,13 @@ class CheckinLicenseNotification extends Notification** @param $params*/- public function __construct($params)+ public function __construct(License $license, $checkedOutTo, User $checkedInBy, $note){- $this->target = $params['target'];- $this->item = $params['item'];- $this->admin = $params['admin'];- $this->note = '';- $this->settings = $params['settings'];- $this->target_type = $params['target_type'];-- if (array_key_exists('note', $params)) {- $this->note = $params['note'];- }-+ $this->target = $checkedOutTo;+ $this->item = $license;+ $this->admin = $checkedInBy;+ $this->note = $note;+ $this->settings = Setting::getSettings();}/**