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

IrimieAndrei's avatar

Pass empty fields on the update method using Request

I'm getting data through a classic submitted form but for some reason I don't get all the input's data in request and it only updates the received ones.

Model::find($id)->update($request->all());

This is a bit problematic because I have multiple nullable fields in my database and sometimes I want to pass empty fields (i.e when a user clear an input then submit the form)

Do you know a way to pass empty fields to the Request as well?

0 likes
3 replies
bobbybouwmann's avatar

Are you sure the data is correctly posted? Disabled fields are not posted by default in browsers! Can you show how you post your data?

Also when you update a model you need to make sure all fields are fillable. So you can either use the $fillable array for that on the model class or the $guarded array.

Documentation: https://laravel.com/docs/5.6/eloquent#mass-assignment

IrimieAndrei's avatar

Yes, I don't have any disabled inputs and I can see the empty fields if I log the request on my web application. But then I make an API request using GuzzleHTTP to store the data and somehow the request is filtered and I don't get empty values anymore.

All fields are fillable in $fillable array

Please or to participate in this conversation.