我正在尝试在MySQL数据库中动态插入复选框值,现在的问题是数组到字符串的转换
我试图动态插入复选框值
这是Controller.php
public function store(Request $request)
{
$this->validate($request,[
'com_name' =>'required',
'per_name' =>'required',
'price' =>'required',
'email' =>'required',
'mobile' =>'required',
'status' =>'required',
'service' =>'required',
'source' =>'required',
'address' =>'required',
'update' =>'required'
]);
//Create Dalywork
if (Auth::check())
{
$user = Auth::User()->id;
$dailyworks = new Dailywork;
$dailyworks->com_name = $request->input('com_name');
$dailyworks->user_id = $user;
$dailyworks->per_name = $request->input('per_name');
$dailyworks->price = $request->input('price');
$dailyworks->email = $request->input('email');
$dailyworks->mobile = $request->input('mobile');
$dailyworks->status = $request->input('status');
$dailyworks->service = $request->input('service');
$dailyworks->source = $request->input('source');
$dailyworks->address = $request->input('address');
$dailyworks->update = $request->input('update');
$dailyworks->save();
return redirect()->route('dailywork.index')->with('success','Report hsa been Create Successfully');
// echo "<pre>";
// print_r($dailyworks);
}
}
我的HTML代码
@foreach($service as $services)
<label class="checkbox-inline">
<input type="checkbox" value="{{$services->service}}" > {{$services->service}}
</label>
@endforeach
我希望输出保存下来,但这是一个错误的数组到字符串的转换