Skip to content

Instantly share code, notes, and snippets.

@scoumbourdis
Last active October 19, 2019 13:37
Show Gist options
  • Save scoumbourdis/8e50afb8c92e951f7fa3710ce05fe93f to your computer and use it in GitHub Desktop.
Save scoumbourdis/8e50afb8c92e951f7fa3710ce05fe93f to your computer and use it in GitHub Desktop.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;
class Examples extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('url');
}
public function _example_output($output = null) {
if (isset($output->isJSONResponse) && $output->isJSONResponse) {
header('Content-Type: application/json; charset=utf-8');
echo $output->output;
exit;
}
$this->load->view('example.php',(array)$output);
}
public function index() {
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
public function customers_management() {
$crud = $this->_getGroceryCrudEnterprise();
$crud->setTable('Customers');
$crud->setSubject('Customer', 'Customers');
$output = $crud->render();
$this->_example_output($output);
}
private function _getDbData() {
return [
'adapter' => [
'driver' => 'Pdo_Pgsql',
'database' => 'my_database_name',
'username' => 'my_username',
'password' => 'my_password'
'charset' => 'utf8'
]
];
}
private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
$db = $this->_getDbData();
$config = include(APPPATH . 'config/gcrud-enteprise.php');
$groceryCrud = new GroceryCrud($config, $db);
return $groceryCrud;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment