I have a resource and I'm trying to set up the update controller. In my case my edit form has many inputs and I need to update the database with them but there might be columns in the database not changed by the edit form. So I have my controller like this:
public function update($id)
{
$hostess = Hostess::find($id);
$inputs=Input::all();
foreach ($inputs as $key => $value) {
$hostess->$key= $value;
}
if ($hostess->save())
{
return Redirect::route('hostesses.show', $hostess->id);
}
return Redirect::back()->withInput()->withErrors($hostess->getErrors());
}
This gives me an error because I am using PUT in my view and I get
Column not found: 1054 Unknown column '_method' in 'field list'
Because my Input::all() is getting the hidden inputs for the PUT method. I can use Input::except() for that, but is that the proper way of updating with laravel?