1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Requests/Subscription/UpdateSubscriptionRequest.php

74 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2021-03-10 01:08:58 +01:00
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2021-03-10 01:08:58 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-03-10 01:08:58 +01:00
*/
namespace App\Http\Requests\Subscription;
use App\Http\Requests\Request;
use App\Utils\Traits\ChecksEntityStatus;
use Illuminate\Validation\Rule;
class UpdateSubscriptionRequest extends Request
{
use ChecksEntityStatus;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->user()->can('edit', $this->subscription);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function 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' => ['sometimes', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)],
];
2021-04-06 00:19:27 +02:00
return $this->globalRules($rules);
}
2022-06-24 03:55:41 +02:00
public function prepareForValidation()
{
$input = $this->all();
$input = $this->decodePrimaryKeys($input);
$this->replace($input);
}
}