mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
backend form validation. +cleanup
This commit is contained in:
parent
bebb72a04f
commit
d262638a63
|
@ -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],
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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' => [
|
||||
|
|
|
@ -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-->
|
||||
|
|
Loading…
Reference in a new issue