I have a strange issue going on. I can't seem to get a record to delete via ajax submission. I'm not seeing anything wrong as this worked previously on Laravel 4. Do I need to provide the CSRF token to the method? If I change my route to any instead of post or delete and hit it directly it will delete as expected.
{!! HTML::link(url(), 'Delete', array('class' => 'btn btn-delete', 'data-name' => $tile->tile_name, 'id' => $tile->id)) !!}
Ajax
var id = $this.attr('id');
// Submit delete request to route with id
$.post('edit/delete/' + id);
// Redirect to gallery
window.location.href = 'http://ims-tiles.dev/';
Route
$router->post('edit/delete/{id}', [
'as' => 'tile.destroy',
'uses' => 'TileController@destroy'
]);
Destroy Method
public function destroy($id) {
$tile = Tile::find($id);
$tags = explode(' ', $tile->getTags());
$tagIds = [];
foreach($tags as $tag){
array_push($tagIds, $tile->getTagId($tag));
}
$tile->tags()->detach($tagIds);
$tile->delete();
}