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;
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();
}
/**

View file

@ -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',

View file

@ -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();
}
/**