Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ricardo's avatar

FormRequest Sanitizer

# in a form request

public function sanitize()
{
  $this->merge([
    'slug' => 'sanitized-slug',
  ]);

  return $this->all();
}

public function validator(Illuminate\Validation\Factory $factory)
{
  return $factory->make(
    $this->sanitize(), $this->container->call([$this, 'rules']), $this->messages()
  );
}

@pmall

0 likes
0 replies

Please or to participate in this conversation.