Reputation: 63
I have a package what I made at Laravel 5.8. When I installed it in a new project with Laravel 6.0, DELETE and PUT methods returned an error.
The DELETE method is not supported for this route. Supported methods: GET, HEAD, POST.
When I wrote at composer.json Laravel 5.8 and reinstalled composer -- it worked. So trouble at version.
Also, this shows me all my routes.
php artisan route:list
I use resource routes like:
Route::resource('langs', 'Sashaef\TranslateProvider\Controllers\LangsController');
Form
<form id="myForm" action="{{ route('langs.update', [ 'id' => 0 ]) }}"
method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" name="_method" value="PUT"/>
Upvotes: 0
Views: 1142
Reputation: 15859
I'm pretty sure this is caused by how you call the route.
Route::resource('langs', 'xController');
Should generate the following update route
Methods:PUT|PATCH
Uri: langs/{lang}
Name: langs.update
You can verify this by running php artisan r:l --name=langs.update
You're also calling it wrong
# WRONG WAY
route('langs.update', ['id' => 0]) // yields: /langs?id=0
# RIGHT WAY
route('langs.update', ['lang' => 0]) // yields: /langs/0
You can verify this in a tinker session
Upvotes: 1