(08-27-2018, 11:12 PM)kaitenz Wrote: Another question.
What if I load a model to a specific controller but that model is dependent to the other model?
Should I load also the "other model"?
Model methods are meant to be reused from multiple controllers as and when required.
We just need to load that model in the controller function before using its method.
For e.g. a code snippet to print invoice will use couple of models
PHP Code:
function printinvoiceMulti($invoiceid){
$this->load->model('log_in');
$userrights=$this->log_in->check_user_type();
$data['userrights']=$userrights;
$this->load->model('program_model');
$data['unitdetail']=$this->program_model->checkunitcode();
$this->load->model('invoice_model');
$data['all_reservation']=$this->invoice_model->all_reservation_for_invoiceprint($invoiceid);
$data['alltaxgroup_items']=$this->invoice_model->get_taxgroup_items($invoiceid);
$data['allreservationaddons']=$this->invoice_model->all_reservation_addons($invoiceid);
$count = count($data['all_reservation']);
if($data['all_reservation']!=null){
$this->load->view('invoice/print_invoice_multi_res',$data);
}else{
redirect(base_url());
}
}