note box is now missing when unchecking setting

This commit is contained in:
akemidx 2024-10-02 18:52:33 -04:00
parent 06e3bb7fd1
commit e00a1aec02
4 changed files with 12 additions and 4 deletions

View file

@ -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'));
}

View file

@ -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'));
}

View file

@ -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;

View file

@ -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;