0
I got this Error by putting a project on the server and trying to insert a product into the database.
Error
Whoops, looks like Something Went Wrong. (1/1) Methodnotallowedhttpexception in Routecollection.php (line 251)
Web.php
route::GET('/','ProdutoController@lista');
Route::GET('/welcome', function () {
return view('welcome');
});
Route::group(['prefix' => 'produtos'], function(){
Route::GET('/', 'ProdutoController@lista');
Route::GET('/json', 'ProdutoController@listaJson');
Route::GET('/mostra/{id}', 'ProdutoController@mostra');
Route::GET('/novo', 'ProdutoController@novo');
Route::POST('/adiciona', 'ProdutoController@adiciona');
Route::GET('/remove/{id}', 'ProdutoController@remove');
});
Route::GET('/leitura', 'ProdutoController@LerTXT');
Route::GET('/login', 'LoginController@form');
Route::POST('/login', 'LoginController@login');
Page that gives the error:
@extends('principal')
@section('conteudo')
<h1>Novo produto</h1>
@if($errors->any())
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
<form action="/produtos/adiciona/" method="POST">
<input type="hidden" name="_token" value="{{csrf_token()}}">
<div class="form-group">
<label>Nome</label>
<input class="form-control" value="{{ old('nome')}}" type="text" name="nome">
</div>
<div class="form-group">
<label>Valor</label>
<input class="form-control" value="{{ old('valor')}}" type="number" name="valor">
</div>
<div class="form-group">
<label>Quantidade em estoque</label>
<input class="form-control" value="{{ old('quantidade')}}" type="number" name="quantidade">
</div>
<div class="form-group">
<label>Tamanho</label>
<input class="form-control" value="{{ old('tamanho')}}" type="text" name="tamanho">
</div>
<div class="form-group">
<label>Categoria</label>
<select class="form-control" type="text" name="categoria_id">
@foreach($categorias as $c)
<option value="{{$c->id}}">{{$c->nome}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label>Descricao</label>
<textarea class="form-control" value="{{ old('descricao')}}" name="descricao"></textarea>
</div>
<button type="submit" class="btn btn-primary">Adicionar</button>
</form>
@stop
When I was on my machine it was running smoothly, on my pc it runs php 7.1.1 and on the server it runs 7.0
You registered a route to
/adiciona
, but in the form you send it to/produtos/adiciona/
. Is that right? The group prefix appears in the page path/adiciona
? If not, you have to change in the form and remove/produtos
ofaction
.– user86792
I put in a group to make it easier to understand then all who are in the group start from /products, soon at the end gets /products/adds
– Luiz Claudio
has a typo:
route::GET('/','ProdutoController@lista');
would not beRoute::GET('/','ProdutoController@lista');
?– novic
no, because the route that is giving problem is Route::POST('/adds', 'Productocontroller@adds');
– Luiz Claudio