Validation for trying to add same country
This commit is contained in:
parent
34064f8b7c
commit
5569375ba2
|
|
@ -15,6 +15,7 @@ namespace App\Http\Requests\EInvoice\Peppol;
|
|||
use App\Models\Country;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class AddTaxIdentifierRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -72,7 +73,11 @@ class AddTaxIdentifierRequest extends FormRequest
|
|||
$company = $user->company();
|
||||
|
||||
return [
|
||||
'country' => ['required', 'bail', Rule::in(array_keys(self::$vat_regex_patterns))],
|
||||
'country' => ['required', 'bail', Rule::in(array_keys(self::$vat_regex_patterns)), function ($attribute, $value, $fail) use ($company) {
|
||||
if ($this->country_id == $company->country()->id) {
|
||||
$fail(ctrans('texts.country_not_supported'));
|
||||
}
|
||||
}],
|
||||
'vat_number' => [
|
||||
'required',
|
||||
'string',
|
||||
|
|
|
|||
Loading…
Reference in New Issue