Skip to content
Taufik Firmansyah edited this page Jul 15, 2015 · 2 revisions

Every controller generated by code builder will have same structure and code

Controller code
class ModuleController extends SB_Controller {
  
  protected $layout   = "layouts/main";
  public $module    = 'ModuleController';
  public $per_page  = '10';
  public function __construct() {
    parent::__construct();
    $this->load->model('ModuleControllerModel');
    $this->model = $this->ModuleControllerModel;
    
    $this->info = $this->model->makeInfo( $this->module);
    $this->access = $this->model->validAccess($this->info['id']); 
    $this->data = array_merge( $this->data, array(
      'pageTitle' =>  $this->info['title'],
      'pageNote'  =>  $this->info['note'],
      'pageModule'  => 'ModuleController',
    ));
  }

  public function index()
  {
    /* Handle table grid , sort order , 
      pagination and search proccess */ 
  }

  function show( $id = null)
  {
    /* Handle view detail*/                        
  }

  function add( $id = null)
  {
    /* Handle form add or edit */ 
  }

  function save()
  {
    /* Handle post form from add or edit */ 
  }

  public function destroy()
  {
    /* Handle multiple delete  */ 

  }             
}

Clone this wiki locally