backend form validation. +cleanup

This commit is contained in:
akemidx 2024-09-04 18:23:36 -04:00
parent bebb72a04f
commit d262638a63
6 changed files with 13 additions and 13 deletions

View file

@ -116,6 +116,12 @@ class AssetCheckinController extends Controller
$seat->update(['assigned_to' => null]);
});
$settings = \App\Models\Setting::getSettings();
if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {
return redirect()->to("hardware/$assetId/checkin")->with('error', trans('admin/hardware/message.update.no_note'));
}
// Get all pending Acceptances for this asset and delete them
$acceptances = CheckoutAcceptance::pending()->whereHasMorph('checkoutable',
[Asset::class],

View file

@ -102,6 +102,10 @@ class AssetCheckoutController extends Controller
$settings = \App\Models\Setting::getSettings();
if($settings->require_checkinout_notes=="1" && (is_null($request->note))) {
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.update.no_note'); //needs translation
}
// We have to check whether $target->company_id is null here since locations don't have a company yet
if (($settings->full_multiple_companies_support) && ((!is_null($target->company_id)) && (!is_null($asset->company_id)))) {
if ($target->company_id != $asset->company_id){

View file

@ -14,18 +14,6 @@ class AssetCheckinRequest extends Request
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
// public function rules()
// {
// 'note' => 'required|in:asset,',
//
// return $rules;
// }
public function response(array $errors)
{
return $this->redirector->back()->withInput()->withErrors($errors, $this->errorBag);

View file

@ -27,7 +27,6 @@ class AssetCheckoutRequest extends Request
'assigned_location' => 'required_without_all:assigned_user,assigned_asset',
'status_id' => 'exists:status_labels,id,deployable,1',
'checkout_to_type' => 'required|in:asset,location,user',
// 'note' => 'required|in:asset,',
'checkout_at' => [
'nullable',
'date',

View file

@ -23,6 +23,7 @@ return [
'nothing_updated' => 'No fields were selected, so nothing was updated.',
'no_assets_selected' => 'No assets were selected, so nothing was updated.',
'assets_do_not_exist_or_are_invalid' => 'Selected assets cannot be updated.',
'no_note' => 'Note field is empty',
],
'restore' => [
@ -76,6 +77,7 @@ return [
'user_does_not_exist' => 'That user is invalid. Please try again.',
'not_available' => 'That asset is not available for checkout!',
'no_assets_selected' => 'You must select at least one asset from the list',
],
'checkin' => [

View file

@ -124,6 +124,7 @@
name="note">{{ old('note', $asset->note) }}</textarea>
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
@endif
</div>
</div> <!--/.box-body-->
</div> <!--/.box-body-->