requested changes

This commit is contained in:
akemidx 2024-10-02 18:15:32 -04:00
parent 6fef127cd1
commit 17706f150e
4 changed files with 18 additions and 2 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

@ -14,6 +14,21 @@ class AssetCheckinRequest extends Request
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [];
if($this->settings->require_checkinout_notes) {
$rules['notes'] = 'required|string';
}
return $rules;
}
public function response(array $errors)
{
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);

View file

@ -99,6 +99,7 @@ class Setting extends Model
protected $casts = [
'label2_asset_logo' => 'boolean',
'require_checkinout_notes' => 'boolean',
];
/**