Level 6
@Xanger i think this should be like
$articoli->id_gioco = implode(',', $request->get('id_gioco'));
$articoli->id_console = implode(',', $request->get('id_console'));
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I have inserted the select and work properly, but if I try to put a multiselect with select2 I have problems.
Controllers:
$articoli = Articoli::find($articleId);
$articoli->id_gioco = $request->get('id_gioco');
$articoli->id_console = $request->get('id_console');
$articoli->save();
Blade:
<select class="col-md-12" name="id_gioco[]" id="id_gioco" multiple>
<option value="0"> Seleziona un'altra Gioco</option>
@foreach($giochi as $gioco)
<option value="{{ $gioco->id }}"
@if ($articoli->id_gioco == $gioco->id)
selected="selected"
@endif
>{{ $gioco->nome }}</option>
@endforeach
</select>
As you can see from the screen, select2 works: https://pasteboard.co/3wftqvvHt.png
Unfortunately, however, I get this error:
(2/2) QueryException
Array to string conversion (SQL: update `articoli` set `id_console` = 4, `updated_at` = 2017-06-30 20:43:30, `id_gioco` = 1129 where `id` = 5675)
Why does not I print both ID?
The correct query should be:
UPDATE `articoli` SET `id_console` = '4,8', `id_gioco` = '1129,1784' WHERE `articoli`.`id` = 5675
@Xanger i think this should be like
$articoli->id_gioco = implode(',', $request->get('id_gioco'));
$articoli->id_console = implode(',', $request->get('id_console'));
Please or to participate in this conversation.