I am getting input from checkbox values in array using bootstrap form. I am using array for storing checkbox values. How i convert this array to string . Because database only take string values.
Here is my code
<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>
In backend i am using laravel to store values to database But it run error that storing array to string in mysql.
public function store(Request $request,AdProfile $adprofile)
{
$adprofile->education = $request->education[];
$adprofile->save();
return redirect()->route('adprofile.profilecomplete');
}
$request->education[]do?implode()function to iterate through the instances of the array and assign it to a string as @Tarasovych said.implode(" ",$request->education)