stevemo / cpanel

Admin Panel for Laravel 4
MIT License
203 stars 67 forks source link

Getting started using Cpanel to protect other routes #9

Closed netm closed 11 years ago

netm commented 11 years ago

Hi,

So to protect a route is nice and easy, something like this in routes.php passes a route through Cpanel:

Route::group(array('before' => 'auth.cpanel'), function() {
    Route::resource('admin/project', 'App\Controllers\ProjectController');
});

However this does not work, it returns an 'Undefined offset: 2' - any ideas why?:

Route::group(array('before' => 'auth.cpanel'), function() {
    Route::get('admin/project', array('as' => 'project.index', 'uses' => 'App\Controllers\ProjectController@index'));
});
stevemo commented 11 years ago

Sorry for the delay.... the auth.cpanel filter accept argument for not standard resource route. By default the filter expect a name route. So in your case Route::group(array('before' => 'auth.cpanel:project.index'), function() { Route::get('admin/project', array('as' => 'project.index', 'uses' => 'App\Controllers\ProjectController@index')); });