I will destroy my user with a HTML link, but it doesn\'t seem to generate the correct link, what am i doing wrong?
public function destroy($id)
{
//Slet
An cool ajax solution that works is this:
function deleteUser(id) {
if (confirm('Delete this user?')) {
$.ajax({
type: "DELETE",
url: 'users/' + id, //resource
success: function(affectedRows) {
//if something was deleted, we redirect the user to the users page, and automatically the user that he deleted will disappear
if (affectedRows > 0) window.location = 'users';
}
});
}
}
Delete
And in the UserController.php we have this method:
public function destroy($id)
{
$affectedRows = User::where('id', '=', $id)->delete();
return $affectedRows;
}