diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index cf881b57c..bc9ae19c8 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\Log; use \Illuminate\Contracts\View\View; use \Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Validator; class AssetCheckinController extends Controller { @@ -40,6 +41,15 @@ class AssetCheckinController extends Controller if (!$asset->model) { return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix')); } + + // Validate custom fields on existing asset + $validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules()); + + if ($validator->fails()) { + return redirect()->route('hardware.edit', $asset) + ->withErrors($validator); + } + $target_option = match ($asset->assigned_type) { 'App\Models\Asset' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset_previous')]), 'App\Models\Location' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.location')]), diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 4d8c9ffda..26a993d80 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Facades\Session; use \Illuminate\Contracts\View\View; use \Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Validator; class AssetCheckoutController extends Controller { @@ -36,6 +37,14 @@ class AssetCheckoutController extends Controller ->with('error', trans('admin/hardware/general.model_invalid_fix')); } + // Validate custom fields on existing asset + $validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules()); + + if ($validator->fails()) { + return redirect()->route('hardware.edit', $asset) + ->withErrors($validator); + } + if ($asset->availableForCheckout()) { return view('hardware/checkout', compact('asset')) ->with('statusLabel_list', Helper::deployableStatusLabelList()) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 6391a3dd9..50810b043 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -877,10 +877,19 @@ class AssetsController extends Controller } - public function audit(Asset $asset) + public function audit(Asset $asset): View | RedirectResponse { - $settings = Setting::getSettings(); $this->authorize('audit', Asset::class); + $settings = Setting::getSettings(); + + // Validate custom fields on existing asset + $validator = Validator::make($asset->toArray(), $asset->customFieldValidationRules()); + + if ($validator->fails()) { + return redirect()->route('hardware.edit', $asset) + ->withErrors($validator); + } + $dt = Carbon::now()->addMonths($settings->audit_interval)->toDateString(); return view('hardware/audit')->with('asset', $asset)->with('item', $asset)->with('next_audit_date', $dt)->with('locations_list'); } diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 8b16a9a72..3f1e4ac8c 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -155,6 +155,7 @@ class AssetsTransformer 'clone' => Gate::allows('create', Asset::class) ? true : false, 'restore' => ($asset->deleted_at!='' && Gate::allows('create', Asset::class)) ? true : false, 'update' => ($asset->deleted_at=='' && Gate::allows('update', Asset::class)) ? true : false, + 'audit' => Gate::allows('audit', Asset::class) ? true : false, 'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) ? true : false, ]; diff --git a/config/version.php b/config/version.php index a94a86b0d..3e400d603 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v8.1.0', - 'full_app_version' => 'v8.1.0 - build 17855-gd81788345', - 'build_version' => '17855', + 'app_version' => 'v8.1.1', + 'full_app_version' => 'v8.1.1 - build 17874-gc031f0b45', + 'build_version' => '17874', 'prerelease_version' => '', - 'hash_version' => 'gd81788345', - 'full_hash' => 'v8.1.0-657-gd81788345', + 'hash_version' => 'gc031f0b45', + 'full_hash' => 'v8.1.1-14-gc031f0b45', 'branch' => 'master', ); \ No newline at end of file diff --git a/resources/views/custom_fields/index.blade.php b/resources/views/custom_fields/index.blade.php index ee2778d77..df70059da 100644 --- a/resources/views/custom_fields/index.blade.php +++ b/resources/views/custom_fields/index.blade.php @@ -198,7 +198,7 @@