Sergio
Sergio

Reputation: 15

laravel resource and angular http

Blog - RESTful Resource Controller

route to the controller Blog

Route::resource('blog', 'BlogController');

Simple query does not work

$http.delete('/blog/1');

return

403 Forbidden

POST(store), GET (index, show), requests work

delete (destroy) does not work

$http.post('/blog/1', {_method: 'DELETE'});

return

405 Method Not Allowed

<?php

class BlogController extends \BaseController {

    public function index()
    {
        return Blog::orderBy('id')->get();
    }

    public function store()
    {
        ....
        ....
    }

    public function edit($id)
    {
        return Blog::find($id);
    }

    public function destroy($id)
    {
        Blog::destroy($id);
    }


}

Upvotes: 0

Views: 931

Answers (1)

spiny_beast
spiny_beast

Reputation: 74

Some web servers may block http delete method. if you use Apache, try to allow it. Add this code to your .htaccess file:

<Limit GET POST DELETE>
  Allow from all
</Limit>

Similar problem was posted here

Hope this helps :)

Upvotes: 1

Related Questions