1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add validation rules for recurring productS

This commit is contained in:
David Bomba 2021-04-14 12:51:22 +10:00
parent 2237939491
commit 986e7fee86
2 changed files with 26 additions and 4 deletions

View File

@ -35,10 +35,11 @@ class StoreSubscriptionRequest extends Request
public function rules()
{
$rules = [
'product_id' => ['sometimes'],
'product_ids' => ['sometimes'],
'recurring_product_ids' => ['sometimes'],
'assigned_user_id' => ['sometimes'],
'is_recurring' => ['sometimes'],
'frequency_id' => ['sometimes'],
'frequency_id' => ['required_with:recurring_product_ids'],
'auto_bill' => ['sometimes'],
'promo_code' => ['sometimes'],
'promo_discount' => ['sometimes'],

View File

@ -13,6 +13,7 @@ namespace App\Http\Requests\Subscription;
use App\Http\Requests\Request;
use App\Utils\Traits\ChecksEntityStatus;
use Illuminate\Validation\Rule;
class UpdateSubscriptionRequest extends Request
{
@ -35,12 +36,32 @@ class UpdateSubscriptionRequest extends Request
*/
public function rules()
{
$rules = [
//
$rules = [
'product_ids' => ['sometimes'],
'recurring_product_ids' => ['sometimes'],
'assigned_user_id' => ['sometimes'],
'is_recurring' => ['sometimes'],
'frequency_id' => ['required_with:recurring_product_ids'],
'auto_bill' => ['sometimes'],
'promo_code' => ['sometimes'],
'promo_discount' => ['sometimes'],
'is_amount_discount' => ['sometimes'],
'allow_cancellation' => ['sometimes'],
'per_set_enabled' => ['sometimes'],
'min_seats_limit' => ['sometimes'],
'max_seats_limit' => ['sometimes'],
'trial_enabled' => ['sometimes'],
'trial_duration' => ['sometimes'],
'allow_query_overrides' => ['sometimes'],
'allow_plan_changes' => ['sometimes'],
'refund_period' => ['sometimes'],
'webhook_configuration' => ['array'],
'name' => ['required', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)]
];
return $this->globalRules($rules);
}
protected function prepareForValidation()