2
votes

I'm using a resource controller to handle accounts in my website. This is my route :

Route::group(['before' => 'auth'], function() {
    Route::resource('/account', 'AccountController');
});

And this is my controller :

class AccountController extends \BaseController {

    public function index() {
        return Redirect::action('AccountController@show', Sentry::getUser()->id);
    }

    public function show($id) {
        return $id;
    }

    public function edit($id) {

    }

    public function update($id) {

    }

    public function destroy($id) {

    }

}

I created the controller with the command line using : 'php artisan controller:make AccountController --except=store,create'

Although, for some reason, I get a NotFoundHttpException when navigating to the URL.

NotFoundHttpException

But I have no idea why. What could be causing this?

EDIT:

Filters :

Route::filter('auth', function()
{
    if ( ! Sentry::check() ) return Redirect::action('HomeController@getLogin');
});
2
what if you remove the leading slash in your route declaration, ie Route::resource('account', 'AccountController');? - Darrrrrren
It still throws the same error. - Liam Potter

2 Answers

2
votes

I fixed it, I don't know what the problem was but I moved the route group to the first line in my routes.php file and it works like a charm.

0
votes

Your code is correct. It works on my machine. It probably is fixable by composer update. It would show a 404 if the Controller isn't findable by the router.

If this doesn't work, double check the auth filter isn't doing anything weird.