vendredi 21 février 2020

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 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', 'HomeController@index')->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', 'EventsController@index')->name('events.index');
        Route::post('/addEvents', 'EventsController@addEvent')->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'))!!}
                              
                             @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>


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32ctwIu
via IFTTT

Aucun commentaire:

Enregistrer un commentaire