0
votes

I've been using Laravel for a while now, although with a new install I did I cannot get the routes POST working, Routes GET works just fine but not post. It keeps throwing a MethodNotAllowedHttpException error. This is my routes

Route::post('/admin/new_event', [ "as" => "admin.event_add", "uses" => "AdminController@adminEventAddPost" ]);

This is my form

<form action="{{ URL::route("admin.event_add") }}" method="POST"> <input type="text" placeholder="Event Title" name="title"><br/> <input type="text" placeholder="Event Detail" name="detail"><br/> <button type="submit" class="btn purp-button">Post</button> </form>

this is the controller

   public function adminEventAddPost()
{

    $title = Input::get("title");
    $detail = Input::get("detail");
    $date = date("Y-m-d");

    Events::create([
        "title" => $title,
        "detail" => $detail,
        "date" => $date
    ]);
    return Redirect::route("admin.events_new");
}
2

2 Answers

0
votes

Try adding {{csrf_field()}} to your form.

-1
votes

Take a look at this if you haven't

https://laravel.com/docs/5.6/csrf

It's about the CSRF Protection.

Like Algridas said in his answer but i think you are using an older version of laravel and you might need to use

@csrf