check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $this->merge([ 'published' => $this->boolean('published'), ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'picto' => [ 'required', new Enum(\App\Enums\Strips\PictoEnum::class) ], 'text' => [ 'required', 'string', 'min:3', // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed function (string $attribute, mixed $value, \Closure $fail) { if (Str::wordCount(\strip_tags($value)) > 255) { $fail(trans('validation.max_words', [ 'attribute' => trans('validation.attributes.text'), 'count' => '255' ])); } } ], 'news_id' => 'nullable|exists:news,id', 'published' => 'required|boolean', 'publish_at' => 'nullable|date', 'unpublish_at' => 'nullable|date|after:publish_at', ]; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'picto' => __('validation.custom.picto'), 'text' => __('validation.attributes.content'), 'news_id' => __('models.classes.news'), 'published' => __('validation.custom.activated'), 'publish_at' => __('validation.custom.publish_at'), 'unpublish_at' => __('validation.custom.unpublish_at'), ]; } }