Added method to bulk checkin (much simpler than checking out)

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-04-16 15:27:15 -07:00
parent 844ad83431
commit 4b66ca6ac5

View file

@ -123,7 +123,25 @@ class LicenseCheckinController extends Controller
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function bulkCheckin() {
public function bulkCheckin(Request $request, $licenseId) {
$license = License::findOrFail($licenseId);
$this->authorize('checkin', $license);
$licenseSeats = LicenseSeat::where('license_id', '=', $licenseId)
->whereNotNull('assigned_to')
->with('user')
->get();
foreach ($licenseSeats as $seat) {
$seat->assigned_to = null;
if ($seat->save()) {
$seat->logCheckin($seat->user, 'Checked in via bulk checkin on license page');
}
}
return redirect()->back()->with('success', 'All licenses checked in successfully!');
}