php - Laravel Route resource MethodNotAllowedHttpException on destroy method -


i using resource laravel route defined following line in routes.php :

route::resource('test', 'app\controllers\teacher\testcontroller', ['only' => ['index', 'create', 'destroy']]); 

the index method works fine. in template of index have created form in order remove item of list.

<form method="delete" action="{{ url::action('app\controllers\teacher\testcontroller@destroy', $audit->id ) }}">     <input type="submit" value="remove" /> </form> 

the url correctly generated laravel when post form following error :

exception 'symfony\component\httpkernel\exception\methodnotallowedhttpexception' in /var/www/project/bootstrap/compiled.php:5365 

i have try change delete post in method attribute of form doesn't work.

i read post doesn't me : methodnotallowedhttpexception on resource defined method laravel-4

when manually create form should use post method, , use _method input delete value way:

<form method="post" action="{{ url::action('app\controllers\teacher\testcontroller@destroy', $audit->id ) }}">     <input type="hidden" name="_method" value="delete" />     <input type="submit" value="remove" /> </form> 

reference in laravel documentation form method spoofing


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -