Skip to content

A free open source IT asset/license management system

Adds checkin events

Till Deekef0acf4710151
diff --git a/app/Events/AccessoryCheckedIn.php b/app/Events/AccessoryCheckedIn.php
new file mode 100644
index 0000000000..812e072b28
--- /dev/null
+++ b/app/Events/AccessoryCheckedIn.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Events;
+
+use App\Models\Accessory;
+use App\Models\Actionlog;
+use App\Models\User;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class AccessoryCheckedIn
+{
+ use Dispatchable, SerializesModels;
+
+ public $accessory;
+ public $checkedOutTo;
+ public $checkedInBy;
+ public $note;
+
+ /**
+ * Create a new event instance.
+ *
+ * @return void
+ */
+ public function __construct(Accessory $accessory, $checkedOutTo, User $checkedInBy, $note)
+ {
+ $this->accessory = $accessory;
+ $this->checkedOutTo = $checkedOutTo;
+ $this->checkedInBy = $checkedInBy;
+ $this->note = $note;
+ }
+}
diff --git a/app/Events/AssetCheckedIn.php b/app/Events/AssetCheckedIn.php
new file mode 100644
index 0000000000..455b2b5d4e
--- /dev/null
+++ b/app/Events/AssetCheckedIn.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Events;
+
+use App\Models\Actionlog;
+use App\Models\Asset;
+use App\Models\User;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class AssetCheckedIn
+{
+ use Dispatchable, SerializesModels;
+
+ public $asset;
+ public $checkedOutTo;
+ public $checkedInBy;
+ public $note;
+
+ /**
+ * Create a new event instance.
+ *
+ * @return void
+ */
+ public function __construct(Asset $asset, $checkedOutTo, User $checkedInBy, $note)
+ {
+ $this->asset = $asset;
+ $this->checkedOutTo = $checkedOutTo;
+ $this->checkedInBy = $checkedInBy;
+ $this->note = $note;
+ }
+}
diff --git a/app/Events/ComponentCheckedIn.php b/app/Events/ComponentCheckedIn.php
new file mode 100644
index 0000000000..283ea6e358
--- /dev/null
+++ b/app/Events/ComponentCheckedIn.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Events;
+
+use App\Models\Actionlog;
+use App\Models\Component;
+use App\Models\User;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class ComponentCheckedIn
+{
+ use Dispatchable, SerializesModels;
+
+ public $component;
+ public $checkedOutTo;
+ public $checkedInBy;
+ public $quantity;
+ public $note;
+
+ /**
+ * Create a new event instance.
+ *
+ * @return void
+ */
+ public function __construct(Component $component, $checkedOutTo, User $checkedInBy, $quantity, $note)
+ {
+ $this->component = $component;
+ $this->checkedOutTo = $checkedOutTo;
+ $this->checkedInBy = $checkedInBy;
+ $this->quantity = $quantity;
+ $this->note = $note;
+ }
+}
diff --git a/app/Events/LicenseCheckedIn.php b/app/Events/LicenseCheckedIn.php
new file mode 100644
index 0000000000..36562296b7
--- /dev/null
+++ b/app/Events/LicenseCheckedIn.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Events;
+
+use App\Models\Actionlog;
+use App\Models\License;
+use App\Models\User;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class LicenseCheckedIn
+{
+ use Dispatchable, SerializesModels;
+
+ public $license;
+ public $checkedOutTo;
+ public $checkedInBy;
+ public $note;
+
+ /**
+ * Create a new event instance.
+ *
+ * @return void
+ */
+ public function __construct(License $license, $checkedOutTo, User $checkedInBy, $note)
+ {
+ $this->license = $license;
+ $this->checkedOutTo = $checkedOutTo;
+ $this->checkedInBy = $checkedInBy;
+ $this->note = $note;
+ }
+}
diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php
index 7eed360a6a..26f77e7fcd 100644
--- a/app/Http/Controllers/Assets/AssetCheckinController.php
+++ b/app/Http/Controllers/Assets/AssetCheckinController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Assets;
+use App\Events\AssetCheckedIn;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Requests\AssetCheckinRequest;
@@ -85,6 +86,8 @@ class AssetCheckinController extends Controller
$asset->logCheckin($target, e(request('note')));
+ event(new AssetCheckedIn($asset, $target, Auth::user(), $request->input('note')));
+
if ($backto=='user') {
return redirect()->route("users.show", $user->id)->with('success', trans('admin/hardware/message.checkin.success'));
}