check(); } /** * Prepare the data for validation. * * @return void */ public function prepareForValidation(): void { $this->merge([ 'content' => $this->input('content') ? Str::of($this->input('content'))->value() : null ]); } /** * Get the validation rules that apply to the request. * * @return array|string> */ public function rules(): array { $rules = [ 'seo_title' => 'nullable', 'seo_description' => 'nullable', 'title' => 'required|min:3|max:255', 'content' => 'nullable', 'data' => 'present|array', 'data.*' => 'required|array', ]; /** @var \App\Models\StaticPage $staticPageModel */ $staticPageModel = request()->route()->parameter('static_page'); if (!$staticPageModel->type->equals(StaticPageType::banner_section)) { $rules = \array_merge( $rules, [ 'seo_title' => 'required|min:45|max:70', 'seo_description' => 'required|min:50|max:160', ], ); } if ( !$staticPageModel->type->equals(StaticPageType::homepage) && !$staticPageModel->type->equals(StaticPageType::our_products) && !$staticPageModel->type->equals(StaticPageType::our_commitments) && !$staticPageModel->type->equals(StaticPageType::banner_section) ) { $rules = \array_merge( $rules, ['content' => ['present']], ); } return $rules; } }