Friday, April 14, 2017

Laravel 5: Use implode() with Eloquent the right way

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>
          
          {!! $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)?



via Yousef Altaf

Advertisement