mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 01:24:34 -04:00
Force at least 1 product quantity
This commit is contained in:
parent
1f1ffd3240
commit
2c25f20a25
@ -29,6 +29,8 @@ class StoreProductRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
$this->sanitize();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'product_key' => 'required|unique:products,product_key,null,null,company_id,'.auth()->user()->companyId(),
|
'product_key' => 'required|unique:products,product_key,null,null,company_id,'.auth()->user()->companyId(),
|
||||||
'cost' => 'numeric',
|
'cost' => 'numeric',
|
||||||
@ -37,5 +39,16 @@ class StoreProductRequest extends Request
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sanitize()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
if($input['quantity'] < 1)
|
||||||
|
$input['quantity'] = 1;
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
|
||||||
|
return $this->all();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -33,6 +33,7 @@ class UpdateProductRequest extends Request
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
//when updating you need to ignore the column ID
|
//when updating you need to ignore the column ID
|
||||||
|
$this->sanitize();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
//'product_key' => 'unique:products,product_key,'.$this->product->id.',id,company_id,'.auth()->user()->companyId(),
|
//'product_key' => 'unique:products,product_key,'.$this->product->id.',id,company_id,'.auth()->user()->companyId(),
|
||||||
@ -42,5 +43,17 @@ class UpdateProductRequest extends Request
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function sanitize()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
if($input['quantity'] < 1)
|
||||||
|
$input['quantity'] = 1;
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
|
||||||
|
return $this->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user