Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

namaraea's avatar

how can i save multiple checkboxes into multiple column using laravel

code saved the last id in array only @foreach($categories as $category) <input class="form-check-input" type="checkbox" id="inlineCheckbox{{++$i}}" value="{{$category->id}}" name="ticket[]" {{ (($order_count_normal < 200 && $category->id=="1") || ($category->id == "2" && $order_count_student < 200)) ? "" : "disabled"}}> {{$category->category_name }} - {{ $category->price}}

                        @endforeach

$validatedData = $request->validate([ 'ticket' => 'required_without_all', ]);// Validated user must check at least one checkbox

foreach ($validatedData['ticket'] as $value) { $order = new Order(); $order->category_id = $value; $order->user_id = auth()->user()->id; $order->save(); }

0 likes
3 replies
namaraea's avatar

i want to store in mulit column becuase each id => foreign ids in another table thanks for reply , i will check it

Snapey's avatar

please format your question correctly. put three backticks on a line before and after your code

Please or to participate in this conversation.