"Controller method not found." in a method that exists

0

I'm starting with the and on a project that already was in progress. I'm trying to access the url link 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 this form exists 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

Being 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');
    
asked by anonymous 04.09.2014 / 14:29

2 answers

1

The route for this action was missing in /app/controllers/route.php

Route::get('purchases/edit/{id}', 'PurchasesController@getEdit');

With the inclusion of this line the error has been corrected and the functionality is perfect.

    
04.09.2014 / 16:44
0

You could declare the route this way:

Route::controller('purchases', 'PurchasesController');

and in your controller puts the filters in the constructor method.

public function __construct() {
    $this->beforeFilter('adminauth');
}

In this way the getEdit, postEdit and other routes added later on the controller would respond.

    
12.11.2014 / 13:25