I am trying to add a record to a database utilizing a resource controller, however, am getting MethodNotAllowedHttpException error. I have gone through several similar questions like this or that ,however, none seem to answer me. This is my code:
Routes.php
Route::resource('animals', 'AnimalsCtrl');
Part of my model.
protected $table='animals';
protected $primaryKey='name';
protected $fillable = [
'name', 'type'
];
The store method in the controller.
public function store(Request $request)
{
$creature = $request->all();
Animal::create($creature);
}
This is the 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>
Cancel
</a>
</td>
</tr>
</table>
</div>
</form>
Does anyone have any suggestion on how I can resolve this?