I have a weird problem with laravel. So this error appears after I click on the edit button
The POST method is not supported for this route. Supported methods: GET, HEAD.
And when I refresh the page it just shows me a form that should be shown. So it means the code is right... right?
Edit.Blade:
<form action="{{ route('categories.update', $category->slug) }}" method="post">
@csrf
@method('put')
<div class="form-group">
<label for="name">Category</label>
<input type="text" name="name" class="form-control" value="{{ $category->name }}">
</div>
<div class="form-group">
<button type="submit" name="btn-updateCategory" class="btn btn-block btn-success">Update category</button>
</div>
</form>
This $category->slug part is not a problem I am sure.. :)
Also when I refresh page and error is gone also my controller does its job (updates category).
It also happened on other project and I thought it is my bad and since I did not know how to solve it and didn't find any mistakes in code, started that project from scratch and finished it without encountering this problem.
EDIT
Here is my route:list https://prnt.sc/tvjw2i
And here is my web.php
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function(){
Route::resource('/posts', 'PostsController');
Route::resource('/categories', 'CategoriesController');
});
Problem solved: Nobody, including me, realised we are looking at the wrong form. Since error appears when I try to go on the update page and not after it, an error was on index.blade.php not on edit.blade.php.