A free open source IT asset/license management system
Updates checkout events to not depend on log
Till Deekee24f292a1a90
diff --git a/app/Events/AccessoryCheckedOut.php b/app/Events/AccessoryCheckedOut.phpindex 397500238d..faf30adb36 100644--- a/app/Events/AccessoryCheckedOut.php+++ b/app/Events/AccessoryCheckedOut.php@@ -22,10 +22,11 @@ class AccessoryCheckedOut** @return void*/- public function __construct(Accessory $accessory, $checkedOutTo, Actionlog $logEntry)+ public function __construct(Accessory $accessory, $checkedOutTo, User $checkedOutBy, $note){$this->accessory = $accessory;$this->checkedOutTo = $checkedOutTo;- $this->logEntry = $logEntry;+ $this->checkedOutBy = $checkedOutBy;+ $this->note = $note;}}diff --git a/app/Events/AssetCheckedOut.php b/app/Events/AssetCheckedOut.phpindex 6d2fdea3a0..1cd0669ad8 100644--- a/app/Events/AssetCheckedOut.php+++ b/app/Events/AssetCheckedOut.php@@ -22,10 +22,11 @@ class AssetCheckedOut** @return void*/- public function __construct(Asset $asset, $checkedOutTo, Actionlog $logEntry)+ public function __construct(Asset $asset, $checkedOutTo, User $checkedOutBy, $note){$this->asset = $asset;$this->checkedOutTo = $checkedOutTo;- $this->logEntry = $logEntry;+ $this->checkedOutBy = $checkedOutBy;+ $this->note = $note;}}diff --git a/app/Events/ComponentCheckedOut.php b/app/Events/ComponentCheckedOut.phpindex 81826a4d2f..f74e7d70f4 100644--- a/app/Events/ComponentCheckedOut.php+++ b/app/Events/ComponentCheckedOut.php@@ -2,7 +2,6 @@namespace App\Events;-use App\Models\Actionlog;use App\Models\Component;use App\Models\User;use Illuminate\Broadcasting\Channel;@@ -15,17 +14,18 @@ class ComponentCheckedOutpublic $component;public $checkedOutTo;- public $logEntry;+ public $checkedOutBy;/*** Create a new event instance.** @return void*/- public function __construct(Component $component, $checkedOutTo, Actionlog $logEntry)+ public function __construct(Component $component, $checkedOutTo, $quantity, User $checkedOutBy){$this->component = $component;$this->checkedOutTo = $checkedOutTo;- $this->logEntry = $logEntry;+ $this->quantity = $quantity;+ $this->checkedOutBy = $checkedOutBy;}}diff --git a/app/Events/ConsumableCheckedOut.php b/app/Events/ConsumableCheckedOut.phpindex df97561c38..ca002cc2f8 100644--- a/app/Events/ConsumableCheckedOut.php+++ b/app/Events/ConsumableCheckedOut.php@@ -22,10 +22,11 @@ class ConsumableCheckedOut** @return void*/- public function __construct(Consumable $consumable, $checkedOutTo, Actionlog $logEntry)+ public function __construct(Consumable $consumable, $checkedOutTo, User $checkedOutBy, $note){$this->consumable = $consumable;$this->checkedOutTo = $checkedOutTo;- $this->logEntry = $logEntry;+ $this->checkedOutBy = $checkedOutBy;+ $this->note = $note;}}diff --git a/app/Events/LicenseCheckedOut.php b/app/Events/LicenseCheckedOut.phpindex 5d1b8335ec..a04b20b7bb 100644--- a/app/Events/LicenseCheckedOut.php+++ b/app/Events/LicenseCheckedOut.php@@ -22,10 +22,11 @@ class LicenseCheckedOut** @return void*/- public function __construct(License $license, $checkedOutTo, Actionlog $logEntry)+ public function __construct(License $license, $checkedOutTo, User $checkedOutBy, $note){$this->license = $license;$this->checkedOutTo = $checkedOutTo;- $this->logEntry = $logEntry;+ $this->checkedOutBy = $checkedOutBy;+ $this->note = $note;}}diff --git a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php b/app/Http/Controllers/Accessories/AccessoryCheckoutController.phpindex 830dbef366..30e5fd25d8 100644--- a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php+++ b/app/Http/Controllers/Accessories/AccessoryCheckoutController.php@@ -82,7 +82,7 @@ class AccessoryCheckoutController extends ControllerDB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();- event(new AccessoryCheckedOut($accessory, $user, $logaction));+ event(new AccessoryCheckedOut($accessory, $user, Auth::user(), $request->input('note'));// Redirect to the new accessory pagereturn redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.checkout.success'));diff --git a/app/Http/Controllers/Components/ComponentCheckoutController.php b/app/Http/Controllers/Components/ComponentCheckoutController.phpindex e2c6adad4f..c979f86186 100644--- a/app/Http/Controllers/Components/ComponentCheckoutController.php+++ b/app/Http/Controllers/Components/ComponentCheckoutController.php@@ -89,7 +89,7 @@ class ComponentCheckoutController extends Controller$logaction = $component->logCheckout(e(Input::get('note')), $asset);- event(new ComponentCheckedOut($component, $asset, $logaction));+ event(new ComponentCheckedOut($component, $asset, $request->input('assigned_qty'), Auth::user()));return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success'));}diff --git a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php b/app/Http/Controllers/Consumables/ConsumableCheckoutController.phpindex b1d75634f9..ef2d30beb3 100644--- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php+++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php@@ -42,7 +42,7 @@ class ConsumableCheckoutController extends Controller* @return \Illuminate\Http\RedirectResponse* @throws \Illuminate\Auth\Access\AuthorizationException*/- public function store($consumableId)+ public function store(Request $request, $consumableId){if (is_null($consumable = Consumable::find($consumableId))) {return redirect()->route('consumables.index')->with('error', trans('admin/consumables/message.not_found'));@@ -70,7 +70,7 @@ class ConsumableCheckoutController extends Controller$logaction = $consumable->logCheckout(e(Input::get('note')), $user);- event(new ConsumableCheckedOut($consumable, $user, $logaction));+ event(new ConsumableCheckedOut($consumable, $user, Auth::user(), $request->input('note')));// Redirect to the new consumable pagereturn redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.checkout.success'));diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.phpindex 570cd6b410..acde2d6205 100644--- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php@@ -2,6 +2,7 @@namespace App\Http\Controllers\Licenses;+use App\Events\LicenseCheckedOut;use App\Http\Requests\LicenseCheckoutRequest;use App\Models\Asset;use App\Models\License;@@ -104,6 +105,9 @@ class LicenseCheckoutController extends Controller}if ($licenseSeat->save()) {$licenseSeat->logCheckout(request('note'), $target);++ event(new LicenseCheckedOut($licenseSeat->license, $target, Auth::user(), request('note')));+return true;}return false;@@ -119,6 +123,9 @@ class LicenseCheckoutController extends Controllerif ($licenseSeat->save()) {$licenseSeat->logCheckout(request('note'), $target);++ event(new LicenseCheckedOut($licenseSeat->license, $target, Auth::user(), request('note')));+return true;}return false;