I'm new to Laravel(8 Version), I am trying to use datatables in Laravel. Successfully I am done with that, but I need to add a edit and delete availability to the each row, I can add edit and delete buttons, But I could not able to achieve the actions(such as delete or edit) It should go to the controllers for edit and delete.
var js_data = '<?php echo json_encode($something); ?>'; // I have taken this object from the controller.
var js_obj_data = JSON.parse(js_data); // I have converted to array object In order to use in JS
$('#somethings').DataTable({
searching:true,
'ordering':false,
'data': js_obj_data,
'resposive':true,
'columns' :[
{ data: "id"},
{ data: "name"},
{ data: "batch"},
{ data: "expire_date"},
{ data: "category"},
{ data: "gst"},
{ data: "rack_no"},
{ defaultContent: '<button> Edit</button>' },// Here I need to add the action routes such like <form action="{{route('something.destroy', $something->id)}}" method="POST" >
<input type="hidden" name="_method" value="DELETE">
<input type[enter image description here][1]="hidden" name="_token" value="csrf_token()}}"
<button class="btn btn-danger m-1">Delete</button>'
Route::resource('/something',SomeController::class)->middleware(IsAdmin::class); //This is my main route
<a href="{{ route('something.edit', $something->id )}}" class="btn btn-primary m-1">Edit</a> // This is for edit
<form action="{{ route('something.destroy', $something->id) }}" method="POST">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button class="btn btn-danger m-1">Delete</button> </form>// This is for delete
I need to add these two actions In my datatable buttons