Try
public function mail(Request $request)
{
$checkboxes = $request->input('checkbox');
foreach($checkboxes as $id) {
DB::table('customer')->where('id', $id)->delete();
}
return redirect('crews/create');
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a page where i am showing some content in tables. I am giving check box for each and row and a button on top. Now i want to send the selected check box id's to the controller. this is what i tried till now. Please some one help me with that, i have been trying this from 4 days.
<a href="sendmail" id="btn-mail" class="btn btn-primary">send mail</a>
<form id="active">
<table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%" data-click-to-select="true">
<thead>
<tr>
<th>Select</th>
<th>Added By</th>
<th>Customer Name</th>
<th>State</th>
<th>District</th>
<th>City/Taluk/Mandal</th>
<th>Address</th>
<th>Phone Number</th>
<th>Ordered Date</th>
<th>Device</th>
<th>Quantity</th>
<th>Ready to ship</th>
<th>Language</th>
<th>Ordered Using</th>
<th>Action</th>
<th>More Option</th>
</tr>
</thead>
<tbody>
@foreach($enqu as $enq )
<tr>
<td><input type="checkbox" name="checkbox[]" value="<? php echo $enq->id; ?>"</td>
<td>{{ $enq->name}}</td>
<td>{{ $enq->customer_name}}</td>
<td>{{ $enq->state}}</td>
<td>{{ $enq->district}}</td>
<td>{{ "$enq->city"}}</td>
<td>{{ "$enq->street"}}, {{ "$enq->locality"}}, {{"$enq->PIN_code"}}</td>
<td>{{ $enq->phone}}</td>
<td>{{ $enq->created_at}}</td>
<td>@if($enq->enquiry_for == 1)
SAMRAT
@elseif ($enq->enquiry_for == 2)
YUVARAJ
@elseif ($enq->enquiry_for == 3)
MAHARAJ
@elseif ($enq->enquiry_for == 4)
SAMANTH
@elseif ($enq->enquiry_for == 5)
BHEEMA
@elseif ($enq->enquiry_for == 6)
DEALERSHIP
@elseif ($enq->enquiry_for == 7)
RAKSHAK
@endif </td>
<td>{{ $enq->quantity}}</td>
<td>{{ $enq->finished}}</td>
<td>@if($enq->language == 1)
English
@elseif ($enq->language == 2)
Telugu
@elseif ($enq->language == 3)
Kannada
@elseif ($enq->language == 4)
Tamil
@elseif ($enq->language == 5)
Hindi
@elseif ($enq->language == 6)
Marathi
@endif </td>
<td>@if($enq->enquired_through == 1)
Kisanraja Website
@elseif ($enq->enquired_through == 2)
Vinfinet Website
@elseif ($enq->enquired_through == 3)
Customer Care
@elseif ($enq->enquired_through == 4)
Toll free number
@elseif ($enq->enquired_through == 5)
Facebook
@elseif ($enq->enquired_through == 6)
You Tube
@elseif ($enq->enquired_through == 7)
Amazon
@elseif ($enq->enquired_through == 8)
Others
@endif </td>
<td>@if($enq->finished != $enq->quantity-1)<a href="<?php echo 'available/' .$enq->id ?>">Check Stock /</a>
@elseif($enq->finished == $enq->quantity-1)<a href="<?php echo 'availablefinal/' .$enq->id ?>">Check Stock /</a>
@endif
<a href="<?php echo 'passstatus/' .$enq->customer_id ?>">Pending Order</a></td>
<td><a href="<?php echo 'passvalue/' .$enq->customer_id ?>">Edit </a> / <a href="main.html"> Delete </a></td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
@endsection
@section('page-script')
<script type="text/javascript">
$("#btn-mail").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
</script>
this is my route
Route::get('/sendmail', "CustomerController@mail");
and this is my controller
public function mail(Request $request)
{
$data = Input::all();
foreach($data['checkboxes'] as $id) {
DB::table('customer')->where('id', $id)->delete();
}
return redirect('crews/create');
}
Please or to participate in this conversation.