From ea64abc6072161be72ecefd9ca3042ae89c96c1f Mon Sep 17 00:00:00 2001 From: Till Deeke Date: Sat, 21 Jul 2018 14:01:30 +0200 Subject: [PATCH] Adds checkout events --- app/Events/AccessoryCheckedOut.php | 31 +++++++++++++++++++++++++++++ app/Events/AssetCheckedOut.php | 31 +++++++++++++++++++++++++++++ app/Events/ComponentCheckedOut.php | 31 +++++++++++++++++++++++++++++ app/Events/ConsumableCheckedOut.php | 31 +++++++++++++++++++++++++++++ app/Events/LicenseCheckedOut.php | 31 +++++++++++++++++++++++++++++ app/Models/Asset.php | 6 +++++- 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 app/Events/AccessoryCheckedOut.php create mode 100644 app/Events/AssetCheckedOut.php create mode 100644 app/Events/ComponentCheckedOut.php create mode 100644 app/Events/ConsumableCheckedOut.php create mode 100644 app/Events/LicenseCheckedOut.php diff --git a/app/Events/AccessoryCheckedOut.php b/app/Events/AccessoryCheckedOut.php new file mode 100644 index 0000000000..397500238d --- /dev/null +++ b/app/Events/AccessoryCheckedOut.php @@ -0,0 +1,31 @@ +accessory = $accessory; + $this->checkedOutTo = $checkedOutTo; + $this->logEntry = $logEntry; + } +} diff --git a/app/Events/AssetCheckedOut.php b/app/Events/AssetCheckedOut.php new file mode 100644 index 0000000000..6d2fdea3a0 --- /dev/null +++ b/app/Events/AssetCheckedOut.php @@ -0,0 +1,31 @@ +asset = $asset; + $this->checkedOutTo = $checkedOutTo; + $this->logEntry = $logEntry; + } +} diff --git a/app/Events/ComponentCheckedOut.php b/app/Events/ComponentCheckedOut.php new file mode 100644 index 0000000000..81826a4d2f --- /dev/null +++ b/app/Events/ComponentCheckedOut.php @@ -0,0 +1,31 @@ +component = $component; + $this->checkedOutTo = $checkedOutTo; + $this->logEntry = $logEntry; + } +} diff --git a/app/Events/ConsumableCheckedOut.php b/app/Events/ConsumableCheckedOut.php new file mode 100644 index 0000000000..df97561c38 --- /dev/null +++ b/app/Events/ConsumableCheckedOut.php @@ -0,0 +1,31 @@ +consumable = $consumable; + $this->checkedOutTo = $checkedOutTo; + $this->logEntry = $logEntry; + } +} diff --git a/app/Events/LicenseCheckedOut.php b/app/Events/LicenseCheckedOut.php new file mode 100644 index 0000000000..5d1b8335ec --- /dev/null +++ b/app/Events/LicenseCheckedOut.php @@ -0,0 +1,31 @@ +license = $license; + $this->checkedOutTo = $checkedOutTo; + $this->logEntry = $logEntry; + } +} diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 4805602f34..288cb04068 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1,6 +1,7 @@ save()) { - $this->logCheckout($note, $target); + $loggedAction = $this->logCheckout($note, $target); + + event(new AssetCheckedOut($this, $target, $loggedAction)); + $this->increment('checkout_counter', 1); return true; }