using POST instead of PUT in laravel

603 views Asked by At

I'm using Laravel to build and api based admin control application and I'm using Route:resource instead of regular GET and POST methods.

Just realized my hosting provider DOESN'T ALLOW PUT and DELETE now I need to so now I have to use POST and GET methods.

this is what i have

Route::resource('contacts', 'Admin\\ContactInfoController',['only' => ['create', 'store', 'update']]);
    Route::get('claims/statuses', 'Admin\\ClaimsController@statusCodes');
    Route::get('claims/costcenters', 'Admin\\ClaimsDetailsController@getCostCentres');
    Route::get('claims/{id}/details', 'Admin\\ClaimsController@details');
    Route::get('claims/{id}/messages', 'Admin\\ClaimsController@messages');
    Route::resource('claims', 'Admin\\ClaimsController',['only' => ['index','store','update','destroy','edit']]);
    Route::resource('claims/details', 'Admin\\ClaimsDetailsController',['only' => ['store','update','destroy']]);

What approach might be best in converting my routes from PUT and DELETE to POST and GET?

2

There are 2 answers

1
Marcin Nabiałek On

I don't think it's possible that your hosting provider doesn't allow to put or delete request. If you created API it could be the case but in other cases (you created normal page) you send forms using POST method with hidden field _method set to HTTP verb, so if only your provider supports POST method it will work without a problem. You can read Form method spoofing section about this.

3
rossanmol On

Contact your hosting provided to allow put or delete request, it's part of web development and this is quite limiting.