0👍
Its because your categories array is a two dimensional array. Now when your syncing that data your code looks like this.
$product->categories()->sync([0] => ['0' => ''], false);
that is why the error says, Column not found: 1054 Unknown column '0' in 'field list'
.
Now, to solve your problem, first your categories value must like this
$categories = [2, 1]; // like this one
$categories = [[2], [1]]; // not this one
You may re structure first your categories array before you sync, by doing this
$categories = [];
foreach ($request->categories$key => $category) {
$categories [] = $category[0];
}
$product->categories()->sync($categories, false);
- [Vuejs]-Vue v-model does not seem to be working in modal
- [Vuejs]-How Show Variable in onchange Method in VueJS?
Source:stackexchange.com