ExceptionController error on Laravel 4 route

1

I set up a restore route in my routes.php

<?php

Route::model('user', 'User');
Route::model('comment', 'Comment');
Route::model('post', 'Post');
Route::model('role', 'Role');

Route::resource('upload', 'UploadController');
Route::get('backgroundDefault', 'AdminUsersController@getBackgroundDefault');

Route::group(['prefix' => 'dashboard', 'before' => 'auth'], function()
{
    Route::pattern('user', '[0-9]+');
    Route::pattern('role', '[0-9]+');

    # User Management
    Route::get('manager/users/{user}/show', 'AdminUsersController@getShow');
    Route::get('manager/users/{user}/edit', 'AdminUsersController@getEdit');
    Route::post('manager/users/{user}/edit', 'AdminUsersController@postEdit');
    Route::get('manager/users/{user}/delete', 'AdminUsersController@getDelete');
    Route::get('manager/users/{user}/restore', 'AdminUsersController@getRestore');
    Route::controller('manager/users', 'AdminUsersController');

    # User Role Management
    Route::get('manager/roles/{role}/show', 'AdminRolesController@getShow');
    Route::get('manager/roles/{role}/edit', 'AdminRolesController@getEdit');
    Route::post('manager/roles/{role}/edit', 'AdminRolesController@postEdit');
    Route::get('manager/roles/{role}/delete', 'AdminRolesController@getDelete');
    Route::post('manager/roles/{role}/delete', 'AdminRolesController@postDelete');
    Route::controller('manager/roles', 'AdminRolesController');

    # Optional
    Route::get('faq', 'AdminUsersController@getFaq');
    Route::get('profile', 'AdminUsersController@getProfile');
    Route::get('mural', 'AdminUsersController@getMural');

    # Admin Dashboard
    Route::controller('/', 'AdminDashboardController');
});

Route::group(['prefix' => 'user', 'before' => 'auth'], function()
{
    // User reset routes
    Route::get('reset/{token}', 'UserController@getReset')
    ->where('token', '[0-9a-z]+');
    // User password reset
    Route::post('reset/{token}', 'UserController@postReset')
    ->where('token', '[0-9a-z]+');
    //:: User Account Routes ::
    Route::post('{user}/edit', 'UserController@postEdit')
    ->where('user', '[0-9]+');
});

Route::controller('/', 'UserController');

Route::get('/', ['before' => 'detectLang','uses' => 'UserController@getIndex']);
Route::post('/', ['before' => 'detectLang','uses' => 'UserController@postIndex']);

AdminUsersController , not to be too long, I gave a summary by removing some methods

<?php

class AdminUsersController extends AdminController {


    protected $user;

    protected $role;

    protected $permission;

    public function __construct(User $user, Role $role, Permission $permission)
    {
        parent::__construct();
        $this->user = $user;
        $this->role = $role;
        $this->permission = $permission;
    }

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function getIndex()
    {
        // Title
        $title = Lang::get('admin/users/title.user_management');

        // Show the page
        return View::make('admin.users.index', compact('title'));
    }
...
    public function getDelete($user)
    {
        // checa se usuario logado é o mesmo a ser excluido
        if ($user->id === Confide::user()->id)
        {
            return Redirect::to('dashboard/manager/users')->with('error', Lang::get('admin/users/messages.delete.impossible'));
        }

        //deleta regras
        //AssignedRoles::where('user_id', $user->id)->delete();

        if ($user->delete())
        {
            return Redirect::to('dashboard/manager/users')->with('success', Lang::get('admin/users/messages.delete.success'));
        }
        else
        {
            return Redirect::to('dashboard/manager/users')->with('error', Lang::get('admin/users/messages.delete.error'));
        }
    }

    public function getRestore($user)
    {
        return 'teste';
    }
...

I'm accessing the link

And I'm getting the error ExceptionController

php artisan routes

+--------+----------------------------------------------------------------------
----------------------+----------------+----------------------------------------
---+----------------+---------------+
| Domain | URI
                      | Name           | Action
   | Before Filters | After Filters |
+--------+----------------------------------------------------------------------
----------------------+----------------+----------------------------------------
---+----------------+---------------+
|        | GET|HEAD upload
                      | upload.index   | UploadController@index
   |                |               |
|        | GET|HEAD upload/create
                      | upload.create  | UploadController@create
   |                |               |
|        | POST upload
                      | upload.store   | UploadController@store
   |                |               |
|        | GET|HEAD upload/{upload}
                      | upload.show    | UploadController@show
   |                |               |
|        | GET|HEAD upload/{upload}/edit
                      | upload.edit    | UploadController@edit
   |                |               |
|        | PUT upload/{upload}
                      | upload.update  | UploadController@update
   |                |               |
|        | PATCH upload/{upload}
                      |                | UploadController@update
   |                |               |
|        | DELETE upload/{upload}
                      | upload.destroy | UploadController@destroy
   |                |               |
|        | GET|HEAD backgroundDefault
                      |                | AdminUsersController@getBackgroundDefau
lt |                |               |
|        | GET|HEAD teste
                      |                | Closure
   |                |               |
|        | GET|HEAD dashboard/manager/users/{user}/show
                      |                | AdminUsersController@getShow
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/{user}/edit
                      |                | AdminUsersController@getEdit
   | auth           |               |
|        | POST dashboard/manager/users/{user}/edit
                      |                | AdminUsersController@postEdit
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/{user}/delete
                      |                | AdminUsersController@getDelete
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/{user}/restore
                      |                | AdminUsersController@getRestore
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/index/{one?}/{two?}/{three?}/{four?}
/{five?}              |                | AdminUsersController@getIndex
   | auth           |               |
|        | GET|HEAD dashboard/manager/users
                      |                | AdminUsersController@getIndex
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/create/{one?}/{two?}/{three?}/{four?
}/{five?}             |                | AdminUsersController@getCreate
   | auth           |               |
|        | POST dashboard/manager/users/create/{one?}/{two?}/{three?}/{four?}/{f
ive?}                 |                | AdminUsersController@postCreate
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/show/{one?}/{two?}/{three?}/{four?}/
{five?}               |                | AdminUsersController@getShow
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/edit/{one?}/{two?}/{three?}/{four?}/
{five?}               |                | AdminUsersController@getEdit
   | auth           |               |
|        | POST dashboard/manager/users/edit/{one?}/{two?}/{three?}/{four?}/{fiv
e?}                   |                | AdminUsersController@postEdit
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/delete/{one?}/{two?}/{three?}/{four?
}/{five?}             |                | AdminUsersController@getDelete
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/restore/{one?}/{two?}/{three?}/{four
?}/{five?}            |                | AdminUsersController@getRestore
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/profile/{one?}/{two?}/{three?}/{four
?}/{five?}            |                | AdminUsersController@getProfile
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/faq/{one?}/{two?}/{three?}/{four?}/{
five?}                |                | AdminUsersController@getFaq
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/mural/{one?}/{two?}/{three?}/{four?}
/{five?}              |                | AdminUsersController@getMural
   | auth           |               |
|        | GET|HEAD dashboard/manager/users/background-default/{one?}/{two?}/{th
ree?}/{four?}/{five?} |                | AdminUsersController@getBackgroundDefau
lt | auth           |               |
|        | GET|HEAD|POST|PUT|PATCH|DELETE dashboard/manager/users/{_missing}
                      |                | AdminUsersController@missingMethod
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/{role}/show
                      |                | AdminRolesController@getShow
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/{role}/edit
                      |                | AdminRolesController@getEdit
   | auth           |               |
|        | POST dashboard/manager/roles/{role}/edit
                      |                | AdminRolesController@postEdit
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/{role}/delete
                      |                | AdminRolesController@getDelete
   | auth           |               |
|        | POST dashboard/manager/roles/{role}/delete
                      |                | AdminRolesController@postDelete
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/index/{one?}/{two?}/{three?}/{four?}
/{five?}              |                | AdminRolesController@getIndex
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles
                      |                | AdminRolesController@getIndex
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/create/{one?}/{two?}/{three?}/{four?
}/{five?}             |                | AdminRolesController@getCreate
   | auth           |               |
|        | POST dashboard/manager/roles/create/{one?}/{two?}/{three?}/{four?}/{f
ive?}                 |                | AdminRolesController@postCreate
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/show/{one?}/{two?}/{three?}/{four?}/
{five?}               |                | AdminRolesController@getShow
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/edit/{one?}/{two?}/{three?}/{four?}/
{five?}               |                | AdminRolesController@getEdit
   | auth           |               |
|        | POST dashboard/manager/roles/edit/{one?}/{two?}/{three?}/{four?}/{fiv
e?}                   |                | AdminRolesController@postEdit
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/delete/{one?}/{two?}/{three?}/{four?
}/{five?}             |                | AdminRolesController@getDelete
   | auth           |               |
|        | POST dashboard/manager/roles/delete/{one?}/{two?}/{three?}/{four?}/{f
ive?}                 |                | AdminRolesController@postDelete
   | auth           |               |
|        | GET|HEAD dashboard/manager/roles/data/{one?}/{two?}/{three?}/{four?}/
{five?}               |                | AdminRolesController@getData
   | auth           |               |
|        | GET|HEAD|POST|PUT|PATCH|DELETE dashboard/manager/roles/{_missing}
                      |                | AdminRolesController@missingMethod
   | auth           |               |
|        | GET|HEAD dashboard/faq
                      |                | AdminUsersController@getFaq
   | auth           |               |
|        | GET|HEAD dashboard/profile
                      |                | AdminUsersController@getProfile
   | auth           |               |
|        | GET|HEAD dashboard/mural
                      |                | AdminUsersController@getMural
   | auth           |               |
|        | GET|HEAD dashboard/index/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | AdminDashboardController@getIndex
   | auth           |               |
|        | GET|HEAD dashboard
                      |                | AdminDashboardController@getIndex
   | auth           |               |
|        | GET|HEAD|POST|PUT|PATCH|DELETE dashboard/{_missing}
                      |                | AdminDashboardController@missingMethod
   | auth           |               |
|        | GET|HEAD user/reset/{token}
                      |                | UserController@getReset
   | auth           |               |
|        | POST user/reset/{token}
                      |                | UserController@postReset
   | auth           |               |
|        | POST user/{user}/edit
                      |                | UserController@postEdit
   | auth           |               |
|        | GET|HEAD create/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getCreate
   |                |               |
|        | GET|HEAD index/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getIndex
   |                |               |
|        | GET|HEAD /
                      |                | UserController@getIndex
   | detectLang     |               |
|        | POST index/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@postIndex
   |                |               |
|        | POST /
                      |                | UserController@postIndex
   | detectLang     |               |
|        | GET|HEAD login/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getLogin
   |                |               |
|        | POST login/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@postLogin
   |                |               |
|        | GET|HEAD confirm/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getConfirm
   |                |               |
|        | GET|HEAD forgot/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getForgot
   |                |               |
|        | POST forgot/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@postForgot
   |                |               |
|        | GET|HEAD reset/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getReset
   |                |               |
|        | POST reset/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@postReset
   |                |               |
|        | GET|HEAD logout/{one?}/{two?}/{three?}/{four?}/{five?}
                      |                | UserController@getLogout
   |                |               |
|        | GET|HEAD|POST|PUT|PATCH|DELETE {_missing}
                      |                | UserController@missingMethod
   |                |               |
+--------+----------------------------------------------------------------------
----------------------+----------------+----------------------------------------
---+----------------+---------------+

All routes above restore are working. I already tried to remove my route from the group, change the route path and name of the method, but nothing worked ... I do not know what else to do.

    
asked by anonymous 19.03.2014 / 21:06

1 answer

0

I was able to solve by changing the nomenclature of the route parameter, as {user} by default was returning the User model object

My route stayed like this

Route::get('manager/users/{userRestore}/restore', 'AdminUsersController@getRestore');

My Controller

public function getRestore($id)
    {
        if (User::withTrashed()->where('id', $id)->restore()){
            return Redirect::to('dashboard/manager/users')->with('success', 'Usuario restaurado com sucesso.');
        }else{
            return Redirect::to('dashboard/manager/users')->with('error', 'Não foi possível restaurar o usuario.');
        }
    }
    
20.03.2014 / 21:43