Cleanup checkin notification constructors

This commit is contained in:
Till Deeke 2018-07-21 14:02:56 +02:00
parent ea64abc607
commit 4a71542f23
3 changed files with 24 additions and 43 deletions

View file

@ -2,6 +2,7 @@
namespace App\Notifications; namespace App\Notifications;
use App\Models\Accessory;
use App\Models\Setting; use App\Models\Setting;
use App\Models\SnipeModel; use App\Models\SnipeModel;
use App\Models\User; use App\Models\User;
@ -15,31 +16,19 @@ use Illuminate\Support\Facades\Mail;
class CheckinAccessoryNotification extends Notification class CheckinAccessoryNotification extends Notification
{ {
use Queueable; use Queueable;
/**
* @var
*/
private $params;
/** /**
* Create a new notification instance. * Create a new notification instance.
* *
* @param $params * @param $params
*/ */
public function __construct($params) public function __construct(Accessory $accessory, $checkedOutTo, User $checkedInby, $note)
{ {
$this->target = $params['target']; $this->item = $accessory;
$this->item = $params['item']; $this->target = $checkedOutTo;
$this->admin = $params['admin']; $this->admin = $checkedInby;
$this->note = ''; $this->note = $note;
$this->target_type = $params['target']; $this->settings = Setting::getSettings();
$this->settings = $params['settings'];
if (array_key_exists('note', $params)) {
$this->note = $params['note'];
}
} }
/** /**

View file

@ -2,13 +2,14 @@
namespace App\Notifications; namespace App\Notifications;
use App\Models\Asset;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Bus\Queueable;
use App\Models\User; use App\Models\User;
use Illuminate\Notifications\Notification; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
class CheckinAssetNotification extends Notification class CheckinAssetNotification extends Notification
{ {
@ -20,19 +21,15 @@ class CheckinAssetNotification extends Notification
* *
* @param $params * @param $params
*/ */
public function __construct($params) public function __construct(Asset $asset, $checkedOutTo, User $checkedInBy, $note)
{ {
$this->target = $params['target']; $this->target = $checkedOutTo;
$this->item = $params['item']; $this->item = $asset;
$this->admin = $params['admin']; $this->admin = $checkedInBy;
$this->note = ''; $this->note = $note;
$this->expected_checkin = '';
$this->target_type = $params['target_type'];
$this->settings = $params['settings'];
if (array_key_exists('note', $params)) { $this->settings = Setting::getSettings();
$this->note = $params['note']; $this->expected_checkin = '';
}
if ($this->item->expected_checkin) { if ($this->item->expected_checkin) {
$this->expected_checkin = \App\Helpers\Helper::getFormattedDateObject($this->item->expected_checkin, 'date', $this->expected_checkin = \App\Helpers\Helper::getFormattedDateObject($this->item->expected_checkin, 'date',

View file

@ -2,6 +2,7 @@
namespace App\Notifications; namespace App\Notifications;
use App\Models\License;
use App\Models\Setting; use App\Models\Setting;
use App\Models\SnipeModel; use App\Models\SnipeModel;
use App\Models\User; use App\Models\User;
@ -25,19 +26,13 @@ class CheckinLicenseNotification extends Notification
* *
* @param $params * @param $params
*/ */
public function __construct($params) public function __construct(License $license, $checkedOutTo, User $checkedInBy, $note)
{ {
$this->target = $params['target']; $this->target = $checkedOutTo;
$this->item = $params['item']; $this->item = $license;
$this->admin = $params['admin']; $this->admin = $checkedInBy;
$this->note = ''; $this->note = $note;
$this->settings = $params['settings']; $this->settings = Setting::getSettings();
$this->target_type = $params['target_type'];
if (array_key_exists('note', $params)) {
$this->note = $params['note'];
}
} }
/** /**