So here are the index and destroy function but the delete button is not working properly and just giving me a blank page with the ID
Controller
//this is the index
public function index()
{
if(request()->ajax()) {
return datatables()->of(Aya_div::select('*'))
->addIndexColumn()
->addColumn('action', function ($id) {
$btn = '<a href="'.route("aya_div.show", $id).'" class="edit btn btn-info btn-sm">View</a>';
$btn = $btn.'<a href="'.route("aya_div.edit", $id).'" class="edit btn btn-primary btn-sm">Edit</a>';
$btn = $btn.'<a href="'.route("aya_div.destroy", $id).'" class="edit btn btn-danger btn-sm">Delete</a>';
return $btn;
})
->rawColumns(['action'])
->make(true);
}
return view('aya_div.index');
}
//this is the destroy function
public function destroy($id)
{
$div = Aya_div::find($id);
$div->delete();
return redirect()->route('aya_div.index')->with('successs', 'Data Deleted');
}
I am expecting the way of defining a method in a button