diff --git a/app/Http/Controllers/Accessories/AccessoryCheckinController.php b/app/Http/Controllers/Accessories/AccessoryCheckinController.php index 83d59ab774..7acfe855cd 100644 --- a/app/Http/Controllers/Accessories/AccessoryCheckinController.php +++ b/app/Http/Controllers/Accessories/AccessoryCheckinController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Accessories; +use App\Events\AccessoryCheckedIn; use App\Http\Controllers\Controller; use App\Models\Accessory; use App\Models\User; @@ -46,7 +47,7 @@ class AccessoryCheckinController extends Controller * @throws \Illuminate\Auth\Access\AuthorizationException * @internal param int $accessoryId */ - public function store($accessoryUserId = null, $backto = null) + public function store(Request $request, $accessoryUserId = null, $backto = null) { // Check if the accessory exists if (is_null($accessory_user = DB::table('accessories_users')->find($accessoryUserId))) { @@ -63,6 +64,8 @@ class AccessoryCheckinController extends Controller $return_to = e($accessory_user->assigned_to); $accessory->logCheckin(User::find($return_to), e(Input::get('note'))); + event(new AccessoryCheckedIn($accessory, User::find($return_to), Auth::user(), $request->input('note'))); + return redirect()->route("accessories.show", $accessory->id)->with('success', trans('admin/accessories/message.checkin.success')); } // Redirect to the accessory management page with error diff --git a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php b/app/Http/Controllers/Accessories/AccessoryCheckoutController.php index 50c174f0c1..830dbef366 100644 --- a/app/Http/Controllers/Accessories/AccessoryCheckoutController.php +++ b/app/Http/Controllers/Accessories/AccessoryCheckoutController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Accessories; +use App\Events\AccessoryCheckedOut; use App\Http\Controllers\Controller; use App\Models\Accessory; use App\Models\User; @@ -77,10 +78,12 @@ class AccessoryCheckoutController extends Controller 'assigned_to' => $request->get('assigned_to') ]); - $accessory->logCheckout(e(Input::get('note')), $user); + $logaction = $accessory->logCheckout(e(Input::get('note')), $user); DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first(); + event(new AccessoryCheckedOut($accessory, $user, $logaction)); + // Redirect to the new accessory page return redirect()->route('accessories.index')->with('success', trans('admin/accessories/message.checkout.success')); } diff --git a/app/Http/Controllers/Components/ComponentCheckinController.php b/app/Http/Controllers/Components/ComponentCheckinController.php index 89eab1f5fa..cd070a5067 100644 --- a/app/Http/Controllers/Components/ComponentCheckinController.php +++ b/app/Http/Controllers/Components/ComponentCheckinController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Components; +use App\Events\ComponentCheckedIn; use App\Http\Controllers\Controller; use App\Models\Actionlog; use App\Models\Asset; @@ -102,6 +103,8 @@ class ComponentCheckinController extends Controller DB::table('components_assets')->where('id', '=', $component_asset_id)->delete(); } + event(new ComponentCheckedIn($component, $component_assets, $request->input('checkin_qty'), $request->input('note'))); + return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success')); } diff --git a/app/Http/Controllers/Components/ComponentCheckoutController.php b/app/Http/Controllers/Components/ComponentCheckoutController.php index 8922317faf..e2c6adad4f 100644 --- a/app/Http/Controllers/Components/ComponentCheckoutController.php +++ b/app/Http/Controllers/Components/ComponentCheckoutController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Components; +use App\Events\ComponentCheckedOut; use App\Http\Controllers\Controller; use App\Models\Asset; use App\Models\Component; @@ -86,7 +87,10 @@ class ComponentCheckoutController extends Controller 'asset_id' => $asset_id ]); - $component->logCheckout(e(Input::get('note')), $asset); + $logaction = $component->logCheckout(e(Input::get('note')), $asset); + + event(new ComponentCheckedOut($component, $asset, $logaction)); + 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.php index 6de35ff9e1..b1d75634f9 100644 --- a/app/Http/Controllers/Consumables/ConsumableCheckoutController.php +++ b/app/Http/Controllers/Consumables/ConsumableCheckoutController.php @@ -2,10 +2,11 @@ namespace App\Http\Controllers\Consumables; +use App\Events\ConsumableCheckedOut; +use App\Http\Controllers\Controller; use App\Models\Consumable; use App\Models\User; use Illuminate\Http\Request; -use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Input; @@ -67,7 +68,9 @@ class ConsumableCheckoutController extends Controller 'assigned_to' => e(Input::get('assigned_to')) ]); - $consumable->logCheckout(e(Input::get('note')), $user); + $logaction = $consumable->logCheckout(e(Input::get('note')), $user); + + event(new ConsumableCheckedOut($consumable, $user, $logaction)); // Redirect to the new consumable page return redirect()->route('consumables.index')->with('success', trans('admin/consumables/message.checkout.success')); diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.php index f942aa1e7e..6144c35062 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckinController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Licenses; +use App\Events\LicenseCheckedIn; use App\Models\Asset; use App\Models\License; use App\Models\LicenseSeat; @@ -49,7 +50,7 @@ class LicenseCheckinController extends Controller * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function store($seatId = null, $backTo = null) + public function store(Request $request, $seatId = null, $backTo = null) { // Check if the asset exists if (is_null($licenseSeat = LicenseSeat::find($seatId))) { @@ -89,6 +90,9 @@ class LicenseCheckinController extends Controller // Was the asset updated? if ($licenseSeat->save()) { $licenseSeat->logCheckin($return_to, e(request('note'))); + + event(new LicenseCheckedIn($license, $return_to, Auth::user(), $request->input('note'))); + if ($backTo=='user') { return redirect()->route("users.show", $return_to->id)->with('success', trans('admin/licenses/message.checkin.success')); }