This method should do exactly what you need. Where are you dumping the code?
Apr 11, 2020
6
Level 1
prepareForValidation method not working
Hi I want my slug input sanitized before applying validation rules but when I use prepareForValidation method and die & dump my form request data, I have non-sanitized data again! What I missing here?
Here is what I tried in my controller :
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'slug' => Str::slug($this->slug),
]);
}
Level 122
So, whats your point? Did you understand my reply?
You can only use this function if you use a FormRequest class
Please or to participate in this conversation.