This may be a mass assignment issue, make sure the fields are either in the model's fillable array, or ensure they are not in the model's guarded array.
Jul 22, 2024
6
Level 7
Model update doesn't work.
Hi, I am following the course "Laravel in 30 days". In day 18 shows two ways to update a record: a) Using save method after updating each field. It works fine.
$job = Job::findOrFail($id);
//Option1
$job->Title = request("Title");
$job->Salary = request("Salary");
$job->save();
b) Using the method update by passing an array.
$job = Job::findOrFail($id);
$job->update([
'Title' => request('Title'),
'Salary' => request('Salary')
]);
The second one return true but no update has been done. I dump $job in the second option. I don't know if I miss something.
Please or to participate in this conversation.