Skip to content
Steve edited this page Oct 2, 2013 · 1 revision

##Controller You can put controller wherever you like. However, you must make sure that the class can be autoloaded by Composer. Let's put our controller in app/controllers.

<?php
// app/controllers/AdminPostsController
use Stevemo\Cpanel\Controllers\BaseController;

class AdminPostsController extends BaseController {

    public function index()
    {
        //app/views/post/admin/index
        return View::make('post.admin.index');
    }

}

In app/routes.php we will add the new route and apply the auth.cpanel filter. For more info on filter visit https://github.com/stevemo/cpanel/wiki/Routes,-Permissions-and-Filter

Route::get('admin/post', array(
    'as'     => 'admin.post.index',
    'uses'   => 'AdminPostsController@index',
    'before' => 'auth.cpanel:post.view'
));

Finally open the Cpanel config file located at app/config/packages/stevemo/cpanel/config.php. If this file do not exist you need to publish the package config file by running php artisan config:publish stevemo/cpanel. We will add a new item to the menu array.

'menu' => array(
        'Dashboard' => array('type' => 'single', 'route' => 'admin.home'),
        'Users'     => array('type' => 'dropdown', 'links' => array(
            'Manage Users' => array('route' => 'admin.users.index'),
            'Groups'       => array('route' => 'admin.groups.index'),
            'Permissions'  => array('route' => 'admin.permissions.index')
        )),
        'Posts' => array('type' => 'single', 'route' => 'admin.posts.index'),
    ),

login to your site admin section and you should see "Posts" link in the menu bar. That's it you have access to your controller in the admin section.

Clone this wiki locally