mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Adds back the checkin/checkout events after #5916
This commit is contained in:
parent
775e46288e
commit
17fc59f989
|
@ -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
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue