Support the ongoing development of Laravel.io →
Requests Input Forms

Hello

I want to do a mass assignment from a request, but im facing some trouble with the autogenerated fields that laravel adds.

public function update(Request $request)
{  
     Deposit::where("department_id", 0)->update($request->input());
}

The problem with the above is that i get an error stating the following:

Column not found: 1054 Unknown column '_method' in 'field list' 

Which makes sense, since the _method is not a column in the db, but since i assign all the input with the $request->input() method it takes the '_method' field with it, which is added automaticly.

Is there a way to get around that?

And yes my model is enabled for mass assignment.

I've been able to fix it with following, but i would like a more correct solution

$update = array("keys" => $request->values, ....);
Deposit::where("department_id", 0)->update($update);
Last updated 3 years ago.
0

In your model set the fillable fields and laravel will ignore the rest

protected $fillable = ['name'];

0

softwaredeveloperca said:

In your model set the fillable fields and laravel will ignore the rest

protected $fillable = ['name'];

Thats not quite my experience.. I've set the appropiate columns in my model, but laravel still crashes with the error above, about the '_method' field, which i've not listed as a fillable column.

0

You could use $request->except('_method'); to filter out that specific parameter.

Last updated 9 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.