| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Http\Requests;
- use App\Models\Provider;
- use Illuminate\Foundation\Http\FormRequest;
- class ClientFavoriteProviderByCodeRequest extends FormRequest
- {
- public function authorize(): bool
- {
- return true;
- }
- protected function prepareForValidation(): void
- {
- $this->merge([
- 'code' => Provider::normalizeShareCode($this->input('code')),
- ]);
- }
- public function rules(): array
- {
- return [
- 'client_id' => ['required', 'integer', 'exists:clients,id'],
- 'code' => [
- 'required',
- 'string',
- 'size:'.Provider::SHARE_CODE_LENGTH,
- 'regex:/^['.Provider::SHARE_CODE_ALPHABET.']+$/',
- ],
- ];
- }
- public function messages(): array
- {
- return [
- 'client_id.required' => __('requests.client_favorite_provider.client_required'),
- 'client_id.exists' => __('requests.client_favorite_provider.client_not_found'),
- 'code.required' => __('requests.client_favorite_provider.code_required'),
- 'code.size' => __('requests.client_favorite_provider.code_invalid'),
- 'code.regex' => __('requests.client_favorite_provider.code_invalid'),
- ];
- }
- }
|