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);
In your model set the fillable fields and laravel will ignore the rest
protected $fillable = ['name'];
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.
You could use $request->except('_method');
to filter out that specific parameter.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community