diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php
index d05822a55f..73f4838a6a 100644
--- a/app/Http/Controllers/Assets/AssetCheckinController.php
+++ b/app/Http/Controllers/Assets/AssetCheckinController.php
@@ -12,7 +12,6 @@ use App\Models\CheckoutAcceptance;
use App\Models\LicenseSeat;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Log;
@@ -47,6 +46,10 @@ class AssetCheckinController extends Controller
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in'));
}
+ if (!$asset->model) {
+ return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
+ }
+
return view('hardware/checkin', compact('asset'))->with('statusLabel_list', Helper::statusLabelList())->with('backto', $backto)->with('table_name', 'Assets');
}
@@ -72,6 +75,11 @@ class AssetCheckinController extends Controller
if (is_null($target = $asset->assignedTo)) {
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in'));
}
+
+ if (!$asset->model) {
+ return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
+ }
+
$this->authorize('checkin', $asset);
if ($asset->assignedType() == Asset::USER) {
diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php
index 0cbbb79b6c..36f00f0fc6 100644
--- a/app/Http/Controllers/Assets/AssetCheckoutController.php
+++ b/app/Http/Controllers/Assets/AssetCheckoutController.php
@@ -34,12 +34,17 @@ class AssetCheckoutController extends Controller
$this->authorize('checkout', $asset);
+ if (!$asset->model) {
+ return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
+ }
+
if ($asset->availableForCheckout()) {
return view('hardware/checkout', compact('asset'))
->with('statusLabel_list', Helper::deployableStatusLabelList())
->with('table_name', 'Assets');
}
+
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
}
@@ -62,6 +67,11 @@ class AssetCheckoutController extends Controller
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
}
$this->authorize('checkout', $asset);
+
+ if (!$asset->model) {
+ return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
+ }
+
$admin = Auth::user();
$target = $this->determineCheckoutTarget();
diff --git a/resources/lang/en-US/admin/hardware/general.php b/resources/lang/en-US/admin/hardware/general.php
index f7f8ad4d06..e1472e709c 100644
--- a/resources/lang/en-US/admin/hardware/general.php
+++ b/resources/lang/en-US/admin/hardware/general.php
@@ -15,8 +15,8 @@ return [
'delete_confirm' => 'Are you sure you want to delete this asset?',
'edit' => 'Edit Asset',
'model_deleted' => 'This Assets model has been deleted. You must restore the model before you can restore the Asset.',
- 'model_invalid' => 'The Model of this Asset is invalid.',
- 'model_invalid_fix' => 'The Asset should be edited to correct this before attempting to check it in or out.',
+ 'model_invalid' => 'This model for this asset is invalid.',
+ 'model_invalid_fix' => 'The asset must be updated use a valid asset model this before attempting to check it in or out, or to audit it.',
'requestable' => 'Requestable',
'requested' => 'Requested',
'not_requestable' => 'Not Requestable',
diff --git a/resources/views/hardware/audit.blade.php b/resources/views/hardware/audit.blade.php
index 9713b6fc1e..1192d3cc9f 100644
--- a/resources/views/hardware/audit.blade.php
+++ b/resources/views/hardware/audit.blade.php
@@ -18,7 +18,7 @@
+
@stop
\ No newline at end of file
diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php
index bb02992819..30e6e670a4 100755
--- a/resources/views/hardware/checkout.blade.php
+++ b/resources/views/hardware/checkout.blade.php
@@ -36,7 +36,8 @@