php - Laravel 5: Can't POST to route resource -


i have route resource route::resource('projects', 'projectscontroller'); , when run route:list can see post available.

+--------+----------+--------------------------+------------------+--------------------------------------------------------------+-----------------+ | domain | method   | uri                      | name             | action                                                       | middleware      | +--------+----------+--------------------------+------------------+--------------------------------------------------------------+-----------------+ |        | get|head | projects                 | projects.index   | app\http\controllers\projectscontroller@index                | auth            | |        | post     | projects                 | projects.store   | app\http\controllers\projectscontroller@store                | auth            | |        | get|head | projects/create          | projects.create  | app\http\controllers\projectscontroller@create               | auth            | |        | get|head | projects/{projects}      | projects.show    | app\http\controllers\projectscontroller@show                 | auth            | |        | put      | projects/{projects}      | projects.update  | app\http\controllers\projectscontroller@update               | auth            | |        | patch    | projects/{projects}      |                  | app\http\controllers\projectscontroller@update               | auth            | |        | delete   | projects/{projects}      | projects.destroy | app\http\controllers\projectscontroller@destroy              | auth            | |        | get|head | projects/{projects}/edit | projects.edit    | app\http\controllers\projectscontroller@edit                 | auth            | +--------+----------+--------------------------+------------------+--------------------------------------------------------------+-----------------+ 

when @ /projects/create (shows form) , hit submit button, error saying:

methodnotallowedhttpexception in routecollection.php line 201:   @ routecollection->methodnotallowed(array('get', 'head', 'put', 'patch', 'delete')) in routecollection.php line 188 

is perhaps how defining <form> tag? not using correct action?

<form method="post" action="">

i tried <form method="post" action="{{ url('projects/store') }}">

sorry, noob laravel!

you should posting resource url, not resource/create.

in other words make sure action of form action="/projects" not action="/projects/create"

edit: leave here kind of relevant, , because posted it, forewarning overkill , lot of irrelevant code starting.

for instance, here's blade snippet 1 of sites:

@extends('layouts.master')  @section('title', 'create project')  @section('content')      <h3>create project</h3>      <hr/>      {!! form::open(['action'=>'projectcontroller@store']) !!}          @include('forms/partials/edit_form', ['submit_button_label' => 'add project'])      {!! form::close() !!}       @include('errors.list')  @endsection 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -