芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/app/Http/Requests/PaymentRequest.php
[ 'required', ], 'customer_id' => [ 'required', ], 'exchange_rate' => [ 'nullable', ], 'amount' => [ 'required', ], 'payment_number' => [ 'required', Rule::unique('payments')->where('company_id', $this->header('company')), ], 'invoice_id' => [ 'nullable', ], 'payment_method_id' => [ 'nullable', ], 'notes' => [ 'nullable', ], ]; if ($this->isMethod('PUT')) { $rules['payment_number'] = [ 'required', Rule::unique('payments') ->ignore($this->route('payment')->id) ->where('company_id', $this->header('company')), ]; } $companyCurrency = CompanySetting::getSetting('currency', $this->header('company')); $customer = Customer::find($this->customer_id); if ($customer && $companyCurrency) { if ((string) $customer->currency_id !== $companyCurrency) { $rules['exchange_rate'] = [ 'required', ]; } } return $rules; } public function getPaymentPayload() { $company_currency = CompanySetting::getSetting('currency', $this->header('company')); $current_currency = $this->currency_id; $exchange_rate = $company_currency != $current_currency ? $this->exchange_rate : 1; $currency = Customer::find($this->customer_id)->currency_id; return collect($this->validated()) ->merge([ 'creator_id' => $this->user()->id, 'company_id' => $this->header('company'), 'exchange_rate' => $exchange_rate, 'base_amount' => $this->amount * $exchange_rate, 'currency_id' => $currency, ]) ->toArray(); } }