我正在使用引导程序形式从数组中的复选框值中获取输入。我正在使用数组存储复选框值。我如何将这个数组转换为string。因为数据库仅采用字符串值。
这是我的代码
<div class="form-group col-md-12">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" id="eduPrimary" name="education[]"
class="custom-control-input" value="primary" />
<label class="custom-control-label" for="eduPrimary">primary</label>
</div>
</div>
<div class="form-group col-md-12">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" id="eduSecondary" name="education[]"
class="custom-control-input" value="secondary" />
<label class="custom-control-label" for="eduSecondary">secondary</label>
</div>
</div>
<div class="form-group col-md-12">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" id="eduUniversity" name="education[]"
class="custom-control-input" value="university" />
<label class="custom-control-label"for="eduUniversity">university</label>
</div>
</div>
在后端,我正在使用laravel将值存储到数据库中,但是在mysql中将数组存储为字符串时会运行错误。
public function store(Request $request,AdProfile $adprofile)
{
$adprofile->education = $request->education[];
$adprofile->save();
return redirect()->route('adprofile.profilecomplete');
}
幕布斯7119047
万千封印
白板的微信