Am trying to make functionality where user deletes his/her account using laravel and i am getting the error "The GET method is not supported for this route. Supported methods: PUT."...i dont know what i am doing wrong...
below is my function in UserController
public function del()
{
$user = \User::find(Auth::user()->id);
Auth::logout();
if ($user->delete()) {
return Redirect::route('welcome');
}
}
In blade file
@extends('layouts.app')
@section('content')
<div >
<div >
<div >
<form method="put" action="wipe">
@csrf
<button type="submit" >Dalete Account</button>
</form>
</div>
</div>
</div>
<br/>
@include('footer')
@endsection
My route in web.php looks as follows
Route::put('users/wipe', 'UserController@del')->name('users.wipe');
I will appreciate any help...thanks in advance
CodePudding user response:
You cannot use PUT in the form method attribute:
use "post" and the blade directive @method
<form method="post" action="wipe">
@method('PUT')
However to delete a user, maybe the DELETE method is a better option? (implement the same way as the PUT method)