每当我尝试将某些内容更新到我的数据中时,我总是收到此错误。它最后一次没有发生很多事情,但在放入新的更新函数后,错误不断出现,出于某种原因,它指向我已经输入的新函数,即使我正在更新旧函数。不断收到错误:implode():更新数据时传递的参数无效
控制器:
//update for user
public function edit($id){
$object = user::find($id);
return view('edit', compact('object'));
}
public function update(Request $request, $id){
$object = user::find($id);
$object->Name = $request->input('Name');
$object->update();
return redirect('/home');
}
//update for Schools table
public function edit1($id){
$object2 = school::find($id);
return view('edit1', compact('object2'));
}
public function update1(Request $request, $id){
$object2 = school::find($id);
$test = array();
$test['School'] = implode(' , ', $request->School);
$test['SDate'] = implode(' , ', $request->SDate);
$test['EDate'] = implode(' , ', $request->EDate);
$object2->update($test);
return redirect('/home');
}
//error start here after putting this whole thing in. (I tried putting it into another separate controller but the error still continues)
public function edit2($id){
$object3 = hobby::find($id);
return view('edit2', compact('object3'));
}
public function update2(Request $request, $id){
$object3 = hobby::find($id);
$test2 = array();
$test2['computer_game'] = implode(' , ', $request->computer_game);
$test2['reading_book'] = implode(' , ', $request->reading_book);
$object3->update($test2);
return redirect('/home');
}
错误是突出这个部分,即使当我尝试更新的用户或学校数据
$test2['computer_game'] = implode(' , ', $request->computer_game);
它说
:implode(): Invalid arguments passed
我没有问题更新爱好数据,但它的错误一直指向爱好implode部分。
是否有可能我只能在implode函数上使用update一次?在此先感谢
edit2.blade.php(.584编辑页面,如图所示它是一个数组)
<form class="form-horizontal" method="post" action="{{ url('/user/show/'.$object3->id) }}">
{{ method_field('PUT') }}
{{ csrf_field() }}
<table class="table table-bordered table-hover" id="tab_logic">
<thead>
<tr >
<th class="text-center">
#
</th>
<th class="text-center">
Sports:
</th>
<th class="text-center">
Books read:
</th>
</tr>
</thead>
<tbody>
<tr id='addr0'>
<td>
1
</td>
<td>
<input type="text" name='computer_game[]' class="form-control"/>
</td>
<td>
<input type="text" name='reading_book[]' class="form-control"/>
</td>
</tr>
<tr id='addr1'></tr>
</tbody>
</table>
<input type="submit" class="btn btn-primary" value="Save">
'var_dump($ request-> computer_game)'产生了什么? – mulquin
你能告诉我们var_dump($ request-> computer_game)的返回值吗? – Maraboc
@Maraboc它什么也没有 – blastme