I'm getting this error when I'm trying to assign a value to all the columns in a table.
Controller
public function updateallcompany(Request $request, $id)
{
$active = $request->input('active');
AccessCode::where('company_id', $id)->update([$active, 'active']);
return view('pages.accesscode.showallaccesscodecompany')
->with('success', "AccessCodes Updated");
}
Error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update
access_codes
set0
= Yes,1
= active,updated_at
= 2019-04-11 11:10:03 wherecompany_id
= 2)
You must pass the $active
value to the field active
.
You can see Mass Updates
example on laravel documentation:
https://laravel.com/docs/5.8/eloquent
Try:
AccessCode::where('company_id', $id)->update(['active' => $active]);