Jump to content

How to call function of model through controller


anuragpetkar

Recommended Posts

Here its my controller code am trying to call getPriorities function of reports class

class AdminReportController extends ModuleAdminController
{
 public function __construct()
 {
    $this->bootstrap  = true;
        //$this->table      = 'report_settings';
        //$this->identifier = 'id';
    $this->className  = 'AdminReport';

    parent::__construct();

    $this->allow_export = true;
    $id_lang = $this->context->language->id;


}

public function init()
{
    parent::init();
}

public function initContent(){

    parent::initContent();
    $obj = new Reports();
    $obj->getPriorities();

 

here its my model code

class Reports extends ObjectModel
{    
     public static function getPriorities(){    
        $id_lang = Context::getContext()->language->id;
        
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
            SELECT t.priorities_id, t.priority_color, tl.priorities_title
            FROM '._DB_PREFIX_.'fmm_hd_priorities t
            LEFT JOIN '._DB_PREFIX_.'fmm_hd_priorities_lang tl
                ON (t.priorities_id = tl.priorities_id AND tl.id_lang = '.(int)$id_lang.')
            WHERE t.`priorities_status` = 1
            ORDER BY t.priorities_id'
        );
    }
}

 

getting error


Fatal error: Call to undefined method reports::getPriorities() in C:\xampp\htdocs\DEVELOPMENT\ivape\modules\reports\controllers\admin\AdminReport.php on line 28

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...