我想将多选下拉值保存到数据库中。
这是 blade.php
<select name="namedropdown[]" id="namedropdown" class="selectpicker" multiple data-live-search="true">
<option value="" disabled selected>Nothing selected</option>
@foreach ($tdropdown as $tdrop)
<option value="{{$tdrop}}">{{$tdrop}}</option>
@endforeach
</select>
这是控制器中的保存功能
public function empstore(Request $request){
$employee = new employee();
$employee->namedropdown = $request->input('namedropdown');
$employee->namedropdown = implode(',', $employee->namedropdown);
$employee->save();
return redirect()->route('employee.index')->with('success','Data Added');
}
从我的代码中出现错误Array to string conversion
请帮助我将多选下拉值保存到数据库中。先感谢您。
GCT1015
暮色呼如
陪伴而非守候