我试图在我的方法中使用foreach循环提交多行。但是,当我按提交时,我得到这个数组字符串错误。如何解决此错误?
错误
数组到字符串转换
HTML
{!! Form::open(array('id'=> 'form1')) !!}
<div class = "form-group">
<div class="col-md-6">
{!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
{!! Form::checkbox('interest_id', '1', ['class' => 'formclick submit']) !!}
</div>
</div>
<div class = "form-group">
<div class="col-md-6">
{!! Form::label('title','Title:', ['class' => 'col-md-4 control-label']) !!}
{!! Form::checkbox('interest_id', '2',['class' => 'formclick submit']) !!}
</div>
</div>
<input id = "submit_me" type="button" value="Click Me!" />
{!! Form::close() !!}
控制器
public function store(InterestRequest $interest) {
$interests = Request::all();
$interests = Request::all();
foreach ($interest-> $interests as $inter) {
$interest = new Follower(array(
'user_id' => $interest->get('interest_id'),
'follower_id' => Auth::id()
));
$inter->save();
}
}