CertificationRequest.php
1 <?php 2 3 namespace App\Http\Requests; 4 5 use App\Exceptions\EnisaValidationApiException; 6 use Illuminate\Contracts\Validation\Validator; 7 use Illuminate\Foundation\Http\FormRequest; 8 9 class CertificationRequest extends FormRequest 10 { 11 /** 12 * Determine if the user is authorized to make this request. 13 * 14 * @return bool 15 */ 16 public function authorize(): bool 17 { 18 return true; 19 } 20 21 /** 22 * Get the validation rules that apply to the request. 23 * 24 * @return array<string, mixed> 25 */ 26 public function rules(): array 27 { 28 return [ 29 'id' => 'required|exists:certificates,id' 30 ]; 31 } 32 33 public function messages(): array 34 { 35 return [ 36 'id.required' => 'Missing parameter: id', 37 'id.exists' => 'Invalid id', 38 ]; 39 } 40 41 protected function failedValidation(Validator $validator) 42 { 43 throw new EnisaValidationApiException($validator); 44 } 45 }