0
I’m starting with the Larable and on a project that was already underway.
I’m trying to access the url http://mydomain.com.br/purchases/edit/1 and is always returning.
Symfony Component Httpkernel Exception Notfoundhttpexception
Controller method not found.
Since the controller has these two methods:
public function getEdit($id) {
//
try {
$record = Purchase::whereId($id)->first();
$record->status = ($record->status === 'PENDENTE') ? 'ENTREGUE' : 'PENDENTE';
$record->save();
} catch (EntityNotFoundException $e) {
return Redirect::to('purchases')->with('errors', new MessageBag(array(
"An item with the ID:$id could not be found."
)));
}
return Redirect::to('purchases')->with('success', new MessageBag(array(
'Item Atualizado'
)));
}
public function postEdit($id) {
//
$record = Product::whereId($id)->first();
$record->fill(Input::all());
$record->save();
return Redirect::to('products')->with('success', new MessageBag(array(
'Item Atualizado'
)));
}
and there is this form in view Edit:
@extends('laravel-bootstrap::layouts.interface-edit')
@section('title')
Editar Usuário: {{ $item->name }}
@stop
@section('heading')
<h1>Editar Usuário: <small>{{ $item->name }}</small></h1>
@stop
@section('form-items')
{{-- The title form item --}}
<div class="form-group">
{{ Form::label( "title" , 'Título' , array( 'class'=>'col-lg-2 control-label' ) ) }}
<div class="col-lg-10">
{{ Form::text( "title" , Input::old( "title", $item->title ) , array( 'class'=>'form-control' , 'placeholder'=>'Título' ) ) }}
</div>
</div>
{{-- The content form item --}}
<div class="form-group">
{{ Form::label( "content" , 'Conteúdo' , array( 'class'=>'col-lg-2 control-label' ) ) }}
<div class="col-lg-10">
{{ Form::text( "content" , Input::old( "content", $item->content ) , array( 'class'=>'form-control' , 'placeholder'=>'Conteúdo' ) ) }}
</div>
</div>
{{-- The points form item --}}
<div class="form-group">
{{ Form::label( "points" , 'Pontos' , array( 'class'=>'col-lg-2 control-label' ) ) }}
<div class="col-lg-10">
{{ Form::text( "points" , Input::old( "points", $item->points ) , array( 'class'=>'form-control' , 'placeholder'=>'Pontos' ) ) }}
</div>
</div>
{{-- The image form item --}}
<div class="form-group">
{{ Form::label( "image" , 'Imagem' , array( 'class'=>'col-lg-2 control-label' ) ) }}
<div class="col-lg-10">
{{ Form::text( "image" , Input::old( "image", $item->image ) , array( 'class'=>'form-control' , 'placeholder'=>'Imagem' ) ) }}
</div>
</div>
{{-- The status form item --}}
<div class="form-group">
{{ Form::label( "ststus" , 'Status' , array( 'class'=>'col-lg-2 control-label' ) ) }}
<div class="col-lg-10">
<label class="radio">
{{ Form::radio( "status" , true, $item->status) }} SIM
</label>
<label class="radio">
{{ Form::radio( "status" , false, !$item->status) }} NÃO
</label>
</div>
</div>
@stop
And be Routes
Route::get('auth/logout', 'AuthController@doLogout');
Route::post('auth/login', 'AuthController@doLogin');
Route::post('auth/recuperar', 'AuthController@doRecuperar');
Route::get('admin', 'AuthController@doAdmin');
Route::post('/auth/admin/login', 'AuthController@doLoginAdmin');
// Route::controller( 'admin/products' , 'ProductsController' );
Route::controller('users', 'UsersController', array('before' => 'adminauth'));
Route::controller('products', 'ProductsController', array('before' => 'adminauth'));
Route::controller('purchases/{sort?}', 'PurchasesController', array('before' => 'adminauth'));
Route::controller('/', 'HomeController');
You can post the routes of your application?
– Rodrigo Rigotti
Routes added
– Erlon Charles
My guess is that you just put the class name on the route - you have to put the FQDN there, which is the class name plus the namespace.
– Rodrigo Rigotti
I’ll take a look at it, as I said is the first contact with Laravel and is to solve this problem. HEHE
– Erlon Charles
I entered the route
Route::get('purchases/edit{id}', 'PurchasesController@getEdit');
but it had no effect– Erlon Charles
Missing a bar in
purchases/edit{id}
, that would bepurchases/edit/{id}
. You can see the routes configured in the application with the commandphp artisan routes
.– Rodrigo Rigotti
Corrected and funfou, I will post the solution as answer
– Erlon Charles