diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index ec92070bb4..1d64da98e2 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -118,7 +118,7 @@ class AssetCheckinController extends Controller $settings = \App\Models\Setting::getSettings(); - if($settings->require_checkinout_notes == '1' && (is_null($request->note))) { + if($settings->require_checkinout_notes && (is_null($request->note))) { return redirect()->to("hardware/$assetId/checkin")->with('error', trans('admin/hardware/message.update.no_note')); } diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 0797c86d54..ef60a589d7 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -102,7 +102,7 @@ class AssetCheckoutController extends Controller $settings = \App\Models\Setting::getSettings(); - if($settings->require_checkinout_notes == '1' && (is_null($request->note))) { + if($settings->require_checkinout_notes && (is_null($request->note))) { return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.update.no_note')); } diff --git a/app/Http/Requests/AssetCheckinRequest.php b/app/Http/Requests/AssetCheckinRequest.php index 6e7e8aa6fa..7321aed193 100644 --- a/app/Http/Requests/AssetCheckinRequest.php +++ b/app/Http/Requests/AssetCheckinRequest.php @@ -21,11 +21,12 @@ class AssetCheckinRequest extends Request */ public function rules() { - $setting = + $settings = \App\Models\Setting::getSettings(); $rules = []; - if($setting->require_checkinout_notes == '1') { + if($settings->require_checkinout_notes) { + // dd($settings->require_checkinout_notes); $rules['notes'] = 'required|string|nullable'; } return $rules; diff --git a/app/Http/Requests/AssetCheckoutRequest.php b/app/Http/Requests/AssetCheckoutRequest.php index f48a7d5e53..27372055f8 100644 --- a/app/Http/Requests/AssetCheckoutRequest.php +++ b/app/Http/Requests/AssetCheckoutRequest.php @@ -21,6 +21,8 @@ class AssetCheckoutRequest extends Request */ public function rules() { + $settings = \App\Models\Setting::getSettings(); + $rules = [ 'assigned_user' => 'required_without_all:assigned_asset,assigned_location', 'assigned_asset' => 'required_without_all:assigned_user,assigned_location', @@ -35,6 +37,11 @@ class AssetCheckoutRequest extends Request 'nullable', 'date' ], + + if($settings->require_checkinout_notes) { + // dd($settings->require_checkinout_notes); + $rules['notes'] = 'required|string|nullable'; + } ]; return $rules;