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

deekepMaks's avatar

Why are the fields not changing in the database?

Here is my code:

Request rules:

public function rules(){
        return [
            'firstName' => 'min:2|max:50|required_with:lastName|nullable',
            'lastName' => 'min:2|max:50|required_with:firstName|nullable',
            'username' => ['required', 'min:3', 'max:15', 'regex:/^[a-zA-Z0-9]+$/', Rule::unique('users')->ignore(Auth::user()->id)],
            'dateOfBirth' => 'date|before:today|nullable'
        ];
    }

Controller:

...
 $update = Auth::user()->update($request->validated());
...

The username and date of birth fields change without problems, but the first and last names do not change. I displayed the fields that I get after validation, they contain the first and last name, but for some reason they are not entered into the database.

0 likes
2 replies
Sergiu17's avatar
Sergiu17
Best Answer
Level 60

Could be related to $fillable array in your User model

Please or to participate in this conversation.