It looks like you're new here. If you want to get involved, click one of these buttons!
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/base_module_model.php');
class Invoices_model extends Base_module_model
{
public $foreign_keys = array('corporate_partner_id' => 'corporate_partners_model');
// Required Fields
public $required = array('invoice_date', 'status', 'corporate_partner_id', 'amount_due');
function __construct()
{
parent::__construct('invoices');
}
function list_items()
{
// Join to the Corporate Partners Table
$this->db->join('corporate_partners', 'corporate_partners.id = invoices.corporate_partner_id', 'left');
// Select
$this->db->select('invoices.id, invoices.id AS "Invoice Number", invoice_date, status, corporate_partners.name as "Corporate Partner", amount_due, transaction_id, payment_date, amount_paid');
$data = parent::list_items();
return $data;
}
}
class Invoice_model extends Base_module_record
{
}
An Error Was Encountered
Unable to locate the file: corporate_partners_model.php
Comments
If advanced, you'll need to specify the module like:
public $foreign_keys = array('corporate_partner_id' => array('my_adv_module_name' => 'corporate_partners_model'));
^ Not tested that, it's what it looks like it needs looking at MY_Model::load_model()
Suggestion: The modules section of the documentation could use a lot of expanding, since most of the questions I have are regarding custom modules in Fuel, and judging by the amount of questions on the forum tagged as "Modules" that is also further justification.