check(); } /** * Prepare the data for validation. */ protected function prepareForValidation(): void { $this->merge([ 'customer' => intval($this->customer), 'model' => intval($this->model), 'class' => $this->class, ]); } /** * Get the validation rules that apply to the request. */ public function rules(): array { return [ 'customer' => 'required|integer|exists:customers,id', 'model' => 'required|integer|exists:' . $this->class . ',id', 'class' => [ 'required', // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed function ($attribute, $value, $fail) { if (! Schema::hasTable($value)) { $fail("La table '$value' n'existe pas dans la base de données."); } }, ], ]; } /** * Get custom attributes for validator errors. */ public function attributes(): array { return [ 'customer' => trans('validation.custom.label'), 'model' => trans('validation.custom.model'), 'class' => trans('validation.custom.class'), ]; } }