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

varunkumar's avatar

Pass checkbox values to laravel controller for deleting

I have a table with checkbox

How to pass checked box array values to the controller for deleting.

controller.

public function del(Request $request ) {

 DB::table('master')->delete();

 return redirect ("/works")->with("Success","Deleted Successfully") ;
}
0 likes
2 replies
Nakov's avatar

@varunkumar

in the view you will have this:

@foreach ($array as $data)
     <input type="checkbox" name="documents[]" value="{{ $data->value }}" />
@endforeach 

and in the controller you can get the selected ids using:

$request->documents

Of course make sure that you use your field names there and not what I've used here, as this is just an example.

Snapey's avatar

first step is to create the front end and check by inspecting the request, that you are receiving an array of selected items

Please or to participate in this conversation.