I have a form in route('users.create')
.
I send form data to this function in its contoller:
public function store(UserRequest $request)
{
return redirect(route('users.create'));
}
for validation I create a class in
App\Http\Requests\Panel\Users\UserRequest;
class UserRequest extends FormRequest
{
public function rules()
{
if($this->method() == 'POST') {
return [
'first_name' => 'required|max:250',
It works.
But How can I change first_name
value before validation (and before save in DB)?
(Also with failed validation, I want to see new data in old('first_name')
Update
I try this:
public function rules()
{
$input = $this->all();
$input['first_name'] = 'Mr '.$request->first_name;
$this->replace($input);
if($this->method() == 'POST') {
It works before if($this->method() == 'POST') {
But It has not effect for validation or for old()
function