Reputation: 2763
I have a checkbox
group and want to insert them in my database as val
(1,2,3).
here is my blade
<div class="form-group">
@foreach($extra as $ext)
<div class="checkbox">
<label>
{{ Form::checkbox('extra_services[]', $ext->id, null, ['class' => 'checkbox']) }}
{!! $ext->title !!}
</label>
</div>
@endforeach
</div>
and here is controller
$temp->currency = $request->currency;
$temp->implode($request->extra_services, ',');
$temp->save();
I got
strtolower() expects parameter 1 to be string, array given
what is the right way to insert my checkbox values into my db as (1, 2, 3)?
Upvotes: 3
Views: 35019
Reputation: 1
$locations = implode(', ',Arr::pluck($business->locations, 'name'));
Upvotes: 0
Reputation: 28529
You need change
$temp->implode($request->extra_services, ',');
to
$temp->extra_services = implode(',', $request->extra_services);
Upvotes: 5
Reputation: 1439
I'm assuming you want to assign the value to $temp->extra_services
. The code then should be
$temp->extra_services = collect($request->extra_services)->implode(',');
Upvotes: 4