Php 从Laravel 5中的复选框中获取值

Php 从Laravel 5中的复选框中获取值,php,laravel,checkbox,laravel-5,Php,Laravel,Checkbox,Laravel 5,我正在我的网站上制作报价申请表,需要一些功能方面的帮助。我试图从传递给视图的一组复选框中获取值;像这样: 控制器(getQuote) 控制器(后报价) 查看 然后,我循环遍历传递的数组中的值,并将其显示给用户 <article class="col-md-12 text-left services bx1-margin"> {{ Form::label('services', "Please check all the functionality yo

我正在我的网站上制作报价申请表,需要一些功能方面的帮助。我试图从传递给视图的一组复选框中获取值;像这样:

控制器(getQuote)

控制器(后报价)

查看

然后,我循环遍历传递的数组中的值,并将其显示给用户

<article class="col-md-12 text-left services bx1-margin">
                {{ Form::label('services', "Please check all the functionality you would like to see in your new website:") }}

                {{-- <label for="services">Please check all the functionality you would like to see in your new website.</label> --}}
                <ul>
                @foreach ($services as $servicesid => $service)
                  <li>
                    {{-- {{ Form::checkbox('agree', 1, true) }} --}}
                    <input id="{{$servicesid}}" value="{{$servicesid}}" name="service[{{$servicesid}}]" type="checkbox" class="custom-control-input form-check-input">
                    <span class="custom-control-description">{{$service}}</span>
                    {{-- <input id="s-{{$servicesid}}" name="services" type="checkbox" class="custom-control-input form-check-input"> --}}


                  </li>
                @endforeach
                </ul>
              </article>

我看到一篇帖子,它解释了如何将值设置为
数组[]
,我只是不太确定如何实现。

确保在html表单中使用与
服务[]
相同的名称来输入
类型
复选框

<input id="{{$servicesid}}" value="{{$servicesid}}" name="service[]" type="checkbox" class="custom-control-input form-check-input">


因此,在提交时,只需在
postQuote
方法中检查变量
$request->service
。它应该包含已提交的所有选中输入的数组变量。

确保类型
输入
复选框使用与html表单中的
服务[]
相同的名称

<input id="{{$servicesid}}" value="{{$servicesid}}" name="service[]" type="checkbox" class="custom-control-input form-check-input">


因此,在提交时,只需在
postQuote
方法中检查变量
$request->service
。它应该包含已提交的所有选中输入的数组变量。

谢谢。我将在几分钟内尝试并报告。因此我抑制了所有其他代码并运行'dd($data['service']);'瞧。感谢@h44f33zThanks的支持。我将在几分钟内尝试并报告。因此我抑制了所有其他代码并运行'dd($data['service']);'瞧。谢谢@h44f33z
<input id="{{$servicesid}}" value="{{$servicesid}}" name="service[]" type="checkbox" class="custom-control-input form-check-input">