php - Laravel 5.1 MethodNotAllowedHttpException on store method using Resource Controller -


i trying add record database utilizing resource controller, however, getting methodnotallowedhttpexception error. have gone through several similar questions this or that ,however, none seem answer me. code:

routes.php

route::resource('animals', 'animalsctrl'); 

part of model.

protected $table='animals'; protected $primarykey='name';  protected $fillable = [     'name', 'type' ]; 

the store method in controller.

   public function store(request $request)     {         $creature = $request->all();         animal::create($creature);      } 

this form.

        <form method="post">             <div class="small-6 small-centered large-4 large-centered columns">                 {!! csrf_field() !!}                 <table>                     <tr>                         <th scope="row">name</th>                         <td>                             <input type="text" name="name" maxlength="50" required>                         </td>                     </tr>                     <tr>                         <th scope="row">type</th>                         <td>                             <input type="text" name="type" maxlength="20" required>                         </td>                     </tr>                     <tr>                         <th>                             <button type="submit" class="button success">                                 <i class="fi-plus"></i>                                 add animal                             </button>                         </th>                         <td>                             <a href="{{url('/animals')}}" class="button alert">                                 <i class="fi-x-circle"></i>                                 &nbsp; cancel                             </a>                         </td>                     </tr>                 </table>             </div>         </form> 

does have suggestion on how can resolve this?

when posting form, url posting form ? url should in action . example follows

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

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -