Hey guys I have to Arrays named $keys and $values Like this
keys
array:2 [▼
0 => "1"
1 => "2"
]
values
array:2 [▼
0 => "US"
1 => "Canada"
]
And I want to insert them to the database with my controller :
$keys = $request->key;
$values = $request->value;
$datas = new Collection();
$datas->key_id = $keys;
$datas->value = $values;
$datas->product_id = $product_id;
ProductSearchValuesModel::create($datas);
But this way is not working What is wrong with my code?
items[]['key']anditems[]['value']then you will only have one array in the request and you can loop over it creating the ProductSearchValuesModel(s)