Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

Help with Abstract Classes

$
0
0
I have in controllers folder this controller:

class Observations extends MY_Controller
{
   function __construct(){
       parent::__construct();
       $this->load->model('Observation_model');

   }
}

And in models folder I have this other code in order to make an Abstract Class.

abstract class Observation_model extends CI_Model
{
    const LEAD_OBSERVATION = 0;
    const CLIENT_OBSERVATION = 1;

    protected $id_situacion;
    protected $id_user;
}

Observation_lead_model extends Observation_model
{
    public function __construct($id_situacion,$id_user){

        $this->id_situacion = $id_situacion;
        $this->id_user = $id_user;
    }
}

class Observation_client_model extends Observation_model
{
    public function __construct($id_situacion,$id_user){
        $this->id_situacion = $id_situacion;
        $this->id_user = $id_user;
    }
}

And when I call the URL of the controller, CI returns the next error:

Fatal error: Cannot instantiate abstract class Observation_model in C:\xampp\htdocs\Projects\operarme\system\core\Loader.php

¿How could I implement abstract classess in CI? I want to make factory method pattern. 

Thanks.

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>