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

syntaxerron's avatar

Delete functionality for single and multiple records

I use the destroy() method when deleting single and multiple records. I just want to know if I am using a good approach to handle these both actions in one method or should I create another method like destroyMany() to handle bulk delete? I am passing '/departments/delete/1,2,3' for multiple and '/departments/delete/1' for a single record. Are there also any possible complications if I do this?

public function destroy($id) {

	Department::destroy(explode(",", $id));

	return response()->json([ "message" => "Deleted successfully", "status" => 200 ]);
}

0 likes
1 reply
devingray_'s avatar

Personally I would not handle the ID's in a GET request but rather send an array of ID's in a POST request.

departments/delete

public function destroy(Request $request) {

	Department::destroy($request->id_array);

	return response()->json([ "message" => "Deleted successfully", "status" => 200 ]);
}

Please or to participate in this conversation.