Laravel 将多个供应商id从复选框更新到数据库

Laravel 将多个供应商id从复选框更新到数据库,laravel,Laravel,我需要使用复选框更新数据库中选定的供应商id,但我遇到的问题是,它没有更新所有选定的供应商id,而是只更新数据库中的一个felid。实际上,我在这里从事CRM工作,我想在选中复选框时向供应商发送多个潜在客户 在控制器中更新查询 public function update(Request $request) { $ids = $request->ids; $vendor_id = $request->vendor_id; $leads = DB::tabl

我需要使用复选框更新数据库中选定的供应商id,但我遇到的问题是,它没有更新所有选定的供应商id,而是只更新数据库中的一个felid。实际上,我在这里从事CRM工作,我想在选中复选框时向供应商发送多个潜在客户

在控制器中更新查询

public function update(Request $request)
{

    $ids = $request->ids;
    $vendor_id = $request->vendor_id;

    $leads = DB::table('leads')
            ->where('id', implode(',', $ids))
            ->update(['vendor_id' => $vendor_id]);

    
    //dd($leads);

    return redirect('admin/leads')->with('success', 'lead send successfully');
  
}
我的刀片文件是

            <form action="{{ url('admin/sendall-leads') }}" method="POST">
            
                @csrf
                @method('PUT')
                <div class="pull-right mb-2">
                    <a class="btn btn-primary agsign" href="#" data-toggle="modal" data-target="#myModal"> Assign Leads</a>
                </div> 
                <div class="card"> 
                    <div class="card-body">
                        <h4 class="card-title">New Leads</h4>
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>
                                        <input type="checkbox" class="selectall">
                                        </th>
                                        <th>Name</th>
                                        <th>Email</th>
                                        <th>City</th>
                                        <th>Phone</th>
                                        <th>Service</th>
                                        <th>View</th>
                                        <th>Edit</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($leads as $lead)
                                    <tr>
                                        <td>
                                        <input type="checkbox" name="ids[]" class="selectbox" value="{{ $lead->id }}">
                                        </td>
                                        <td> {{ $lead->customer_name }} </td>
                                        <td> {{ $lead->customer_email }} </td>
                                        <td> {{ $lead->customer_city }} </td>
                                        <td> {{ $lead->customer_phone }} </td>
                                        <td> {{ $lead->service_name }} </td>
                                        <td><a href="{{ route('leads.show',$lead->id) }}" class="btn btn-info btn-sm">view</a></td>
                                        <td>
                                        @if ($lead->vendor_id === NULL) 
                                            <span class="label label-danger">Not Send</span>
                                        @else
                                            <span class="label label-success">Lead Alloted</span>
                                        @endif    
                                        </td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>    
                </div>
                
                <!-- The Modal -->
                <div class="modal" id="myModal">
                    <div class="modal-dialog">
                        <div class="modal-content">

                                <!-- Modal Header -->
                                <div class="modal-header">
                                    <h4 class="modal-title">Send Leads</h4>
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                </div>

                                <!-- Modal body -->
                                <div class="modal-body">
                                        <div class="row">
                                            <div class="col-xs-6 col-sm-6 col-md-12">
                                                <div class="form-group">
                                                    <strong>Select Vendor:</strong>
                                                    <select class="form-control" name="vendor_id" id="vendor_id">
                                                    <option>Select Vendor Name</option>
                                                    @foreach ($users as $user)
                                                        <option value="{{ $user->id }}">{{ $user->name }}</option>
                                                    @endforeach
                                                    </select>
                                                </div>
                                            </div>
                                        </div>    

                                        <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                                        <button formaction="/admin/sendall-leads" type="submit" onclick="return myConfirm();" class="btn btn-primary">Submit</button>
                                        </div>
                                </div>

                                <!-- Modal footer -->
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                </div>

                        </div>
                    </div>
                </div>
        </form>
Route::put('admin/sendall-leads','LeadsController@update');
请帮助我或给我一个解决方案

DB::table('leads')
  ->whereIn('id', $request->input('ids'))
  ->update(['vendor_id' => $request->input('vendor_id')]);