Ad
Laravel - The POST Method Is Not Supported For This Route. Supported Methods: GET, HEAD
I am trying to add an event on a calendar I have created, however I am getting the following error
The POST method is not supported for this route. Supported methods: GET, HEAD
I have used the methods @csrf and {{ method_field('PUT') }} to no avail. I have also cleared route cache which did not help. Any help is much appreciated.
Routes:
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', '[email protected]')->name('home');
Route::namespace('Admin')->prefix('admin')->name('admin.')->group(function(){
Route::middleware('can:manage-users')->group(function(){
Route::resource('/users', 'UsersController', ['except' => ['show']]);
Route::resource('/courses', 'CoursesController', ['except' => ['show']]);
});
Route::middleware('can:manage-calendar')->group(function(){
Route::get('events', '[email protected]')->name('events.index');
Route::post('/addEvents', '[email protected]')->name('events.add');
});
})
index.blade.php
@extends('layouts.app')
@section ('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-14">
<div class="card">
<div class="card-header">Calendar</div>
<div class="card-body">
{!! Form::open(array('route' => 'admin.events.index', 'method' => 'POST', 'files' => 'true'))!!}
{{-- {{method_field('PUT') }}
@csrf --}}
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12"></div>
<div class="col-xs-4 col-sm-4 col-md-4">
<div class="form-group">
{!! Form::label('event_name', 'Event Name:') !!}
<div class="">
{!! Form::text('event_name', null, ['class' => 'form-control']) !!}
{!! $errors->first('event_name', '<p class="alert alert-danger">:message</p>') !!}
</div>
@Collin, I have added the image below in relation to your question
Ad
Answer
Just check your form action url route. You have to pass 'route('admin.events.add)' rather than 'route('admin.events.index')' and also dont use 'PUT' it will accept 'POST' as well.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad