【发布时间】:2019-04-27 00:43:55
【问题描述】:
我的代码中的问题是我无法在数据库 MySQL 中存储或插入数组值,这是我的控制器代码,请帮助我。谢谢。我在 Controller 中的代码没有数组或任何数组。我不知道如何将它变成数组。
控制器
public function store(Request $request)
{
$this->validate($request,[
'city' => 'required'
]);
$citi = new City;
$citi->city = $request->input('city');
$citi->save();
return redirect('/lugar')->with('success', 'Data Inserted');
}
查看
<td> {{Form::text('city[]', '', ['class' => 'form-control name_list', 'placeholder' => 'Add Country'])}} </td>
【问题讨论】:
-
你遇到了什么错误?
-
这里,请参阅_Argument 1 传递给 Illuminate\Database\Grammar::parameterize() 必须是数组类型,给定字符串 _
-
这不是 laravel 而是纯 php。我不明白:(