| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- class PaymentSplitRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return true;
- }
- public function rules(): array
- {
- $rules = [
- 'payment_id' => ['sometimes', 'integer', 'exists:payments,id'],
- 'provider_id' => ['sometimes', 'integer', 'exists:providers,id'],
- 'gateway_provider' => ['sometimes', 'string', 'max:255'],
- 'gateway_entity_reference' => ['nullable', 'string', 'max:255'],
- 'gateway_entity_label' => ['nullable', 'string', 'max:255'],
- 'gateway_operation_reference' => ['nullable', 'string', 'max:255'],
- 'gateway_operation_label' => ['nullable', 'string', 'max:255'],
- 'gateway_parent_reference' => ['nullable', 'string', 'max:255'],
- 'gateway_parent_label' => ['nullable', 'string', 'max:255'],
- 'gateway_transfer_target_reference' => ['nullable', 'string', 'max:255'],
- 'gateway_transfer_target_label' => ['nullable', 'string', 'max:255'],
- 'status' => ['sometimes', 'in:pending,processing,transferred,failed,cancelled'],
- 'gross_amount' => ['sometimes', 'numeric', 'min:0'],
- 'gateway_fee_amount' => ['sometimes', 'numeric', 'min:0'],
- 'net_amount' => ['sometimes', 'numeric', 'min:0'],
- 'transferred_at' => ['nullable', 'date'],
- 'failed_at' => ['nullable', 'date'],
- 'failure_code' => ['nullable', 'string', 'max:255'],
- 'failure_message' => ['nullable', 'string'],
- 'gateway_payload' => ['nullable', 'array'],
- 'metadata' => ['nullable', 'array'],
- ];
- if ($this->isMethod('POST')) {
- $rules['payment_id'] = ['required', 'integer', 'exists:payments,id'];
- $rules['provider_id'] = ['required', 'integer', 'exists:providers,id'];
- $rules['gross_amount'] = ['required', 'numeric', 'min:0'];
- $rules['net_amount'] = ['required', 'numeric', 'min:0'];
- }
- return $rules;
- }
- }
|