A PHP Error was encountered Severity: Warning Message: Missing argument 1 for Cust_proj::__construct(), called in C:\xampp\htdocs\newcargo\system\core\Loader.php on line 353 and defined Filename: models/Cust_Proj.php Line Number: 10 Backtrace: File: C:\xampp\htdocs\newcargo\application\models\Cust_Proj.php Line: 10 Function: _error_handler File: C:\xampp\htdocs\newcargo\application\controllers\TransProject.php Line: 13 Function: model File: C:\xampp\htdocs\newcargo\index.php Line: 315 Function: require_once A PHP Error was encountered Severity: Notice Message: Undefined variable: databaseConfig Filename: models/Cust_Proj.php Line Number: 12 Backtrace: File: C:\xampp\htdocs\newcargo\application\models\Cust_Proj.php Line: 12 Function: _error_handler File: C:\xampp\htdocs\newcargo\application\controllers\TransProject.php Line: 13 Function: model File: C:\xampp\htdocs\newcargo\index.php Line: 315 Function: require_once
My Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
use GroceryCrud\Core\Model;
use GroceryCrud\Core\Model\ModelFieldType;
class Cust_proj extends Model {
protected $ci;
protected $db;
function __construct($databaseConfig) {
$this->setDatabaseConnection($databaseConfig);
$this->ci = & get_instance();
$this->db = $this->ci->db;
}
public function getFieldTypes($tableName)
{
$fieldTypes = parent::getFieldTypes($tableName);
$fullNameFieldType = new ModelFieldType();
$fullNameFieldType->dataType = 'varchar';
$countOrdersFieldType = new ModelFieldType();
$countOrdersFieldType->dataType = 'varchar';
$fieldTypes['barang'] = $fullNameFieldType;
$fieldTypes['qty'] = $countOrdersFieldType;
return $fieldTypes;
}
public function getOne($id)
{
$customer = parent::getOne($id);
$this->db->select('COUNT(*) as qty');
$this->db->where('id_project', $id);
$customer['qty'] = $this->db->get('tbl_item_project')->row()->count_orders;
return $customer;
}
public function getList() {
$order_by = $this->orderBy;
$sorting = $this->sorting;
// All the custom stuff here
$this->db->select('tbl_item_project.id_customer, barang, harga, qty, COUNT(*) as qty', false);
$this->db->join('tbl_item_project', 'tbl_data_project.id_project = tbl_item_project.id_project', 'left');
$this->db->group_by('tbl_item_project.id_project');
if ($order_by !== null) {
$this->db->order_by($order_by. " " . $sorting);
}
if (!empty($this->_filters)) {
foreach ($this->_filters as $filter_name => $filter_value) {
$this->db->like($filter_name, $filter_value);
}
}
if (!empty($this->_filters_or)) {
foreach ($this->_filters_or as $filter_name => $filter_value) {
$this->db->or_like($filter_name, $filter_value);
}
}
$this->db->limit($this->limit, ($this->limit * ($this->page - 1)));
$results = $this->db->get($this->tableName)->result_array();
return $results;
}
public function getTotalItems()
{
return parent::getTotalItems();
}
}
?>
MY Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;
class TransProject extends BaseController {
public function __construct()
{
parent::__construct();
$this->isLoggedIn();
$this->load->database();
$this->load->model('cust_proj');
$this->load->helper('url');
}
public function project_out($output = null)
{
if (isset($output->isJSONResponse) && $output->isJSONResponse) {
header('Content-Type: application/json; charset=utf-8');
echo $output->output;
exit;
}
$this->global['pageTitle'] = 'Aplikai Cargo : Project Data';
$this->loadViews("sethal/project_data", $this->global,(array)$output);
}
public function index()
{
$this->loadThis();
$this->project_out((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
public function setProject()
{
include(APPPATH . 'models/Cust_proj.php');
$this->load->database();
$this->load->model('cust_proj');
$model = new \Cust_proj($db);
$crud->setModel($model);
$crud->setTable('tbl_data_project');
}
}
