I'm getting the next error:
jquery-2.2.4.min.js:4 DELETE http://company.dev/admin/portfolio/settings/category/delete/7 500 (Internal Server Error)
I'm not sure what it is because I think I have the right route and also giving the csrf token (still fairly new to laravel)
Route:
Route::delete('/admin/portfolio/settings/category/delete/{id}', [
'as' => 'categoryDelete',
'uses' => 'PortfolioController@destroy'
]);`enter code here`
Ajax:
$(".deleteProduct").click(function(){
var id = $(this).data("id");
var token = $(this).data("token");
$.ajax(
{
url: "/admin/portfolio/settings/category/delete/"+id,
type: 'DELETE',
dataType: "JSON",
data: {
"id": id,
"_method": 'DELETE',
"_token": token
},
success: function ()
{
console.log("it Work");
}
});
console.log("It failed");
});
Delete button:
<button class="deleteProduct" data-id="{{ $category->category_id }}" data-token="{{ csrf_token() }}" >Delete Category</button>
Delete function:
public function destroy(Request $request, $id)
{
Category::find($id)->delete();
return response()->json([
'success' => 'Record has been deleted successfully!'
]);
}