I am currently using laravel 5.3 with angular. I have few function such as add / edit / delete posts now I decided to have another function which deletes all posts with just a click.
Somehow I checked that everything works up to my service part but after that it doesn't seem to be passing to my controller in laravel.
Can someone let me know if I am using the wrong syntax for angular or laravel?
I have this in web.php
Route::resource('posts', 'PostController');
Route::delete('posts/destroyall', array('as' => 'posts.destroyall', 'uses' => 'PostController@destroyall'));
this in my PostController.php
public function destroyall() {
Post::truncate();
return response()->json(Post::get());
}
this for my controller in angular
$scope.destroyAll = function () {
Post.destroyAll()
.success(function () {
// Use the get() created in Post service
// Gets all the posts
Post.get()
.success(function(getData) {
$scope.posts = (getData);
});
})
}
This in my service
destroyAll : function () {
return $http.delete('/posts/destroyall/');
}
can someone give me an advice please?