Home > Software engineering >  Comments section not forming in Laravel
Comments section not forming in Laravel

Time:04-08

My comments section is not forming in Laravel. I get "The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.", but I do not have POST method anywhere in my web.php. This is it:

<?php

use Illuminate\Support\Facades\Route;


/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use App\Http\Controllers\HomeController;
use App\Http\Controllers\PagesController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\CommentsController;

Route::get('/', [PagesController::class, 'index'])->name('index');

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

Route::resource('/blogs', [BlogController::class, 'index'])->name('blogs');

Auth::routes();

Route::get('/article', [App\Http\Controllers\ArticleController::class, 'index'])->name('article');

Route::get('/create', [App\Http\Controllers\CategoryController::class, 'index'])->name('create');

Route::get('/blogs/{id}', [CommentsController::class, 'index'])->name('blogs');
Route::get('/blogs/{id}', [CommentsController::class, 'store'])->name('blogs');

CodePudding user response:

If you are using "PUT","PATCH","HEAD" or "DELETE" method you need to specify the method in your form like this :

<form method="POST">
@method('delete')
</form>

CodePudding user response:

The problem was in \storage\framework\views\145ba5a124cf3e653f6b59e6acf30206719d86de.php file. Just had to modify the method. Hopefully this is useful.

  • Related