Laravel 5.4 (1/1) MethodNotAllowedHttpException on DELETE method
Before anyone points that is a duplicate I have checked these questions – laravel 5.4 MethodNotAllowedHttpException in RouteCollection.php (line 251), (1/1) MethodNotAllowedHttpException among others.
My problem is that I have done all of the solutions to all of the above posted questions and none have solved my issue.
ProfileController
<?php
namespace AppHttpControllers;
use AppUser;
use IlluminateHttpRequest;
use IlluminateDatabaseEloquentModel;
use IlluminateSupportFacadesDB;
use Auth;
class ProfileController extends Controller
{
//
public function show($name) {
$user = User::whereName($name)->first();
if ($user) {
// User exists
return view('profile')->withUser($user);
} else {
dd($user);
}
}
public function destroy($id){
DB::table('users')->where('id', '=', $id)->delete();
return redirect()->route('/');
}
}
profile.blade
<ul class="profile-hero-header-menu">
<li><a class="button primary" href="#"><i class="fa fa-envelope" aria-hidden="true"></i> Request Changes</a></li>
<li><a class="button success" href="#"><i class="fa fa-life-ring" aria-hidden="true"></i> Contact Support</a></li>
<form action="/profile/{id}/delete" method="POST">
<input type="hidden" name="_method" value="DELETE">
<li><a class="button alert" href="" name="DELETE"><i class="fa fa-trash" aria-hidden="true"></i> Close Account</a></li>
</form>
</ul>
web
Route::delete('/profile/{id}/delete', 'ProfileController@destroy')->name('profile.destroy')->middleware('auth');
On user click “Close Account” throws an exception –
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-5-4-1-1-methodnotallowedhttpexception-on-delete-method/
via Lzo Media
No comments:
Post a Comment