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") ;
}
@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.
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.