<?php

class Cpeprovisioning extends mfBaseModel {
  protected $forcestr = ["wifi_ssid", "wifi_pass"];
  
  private $order;
  private $orderproduct;
  private $termination;
  private $external_finisher;
  private $creator;
  private $editor;
  
  public function getProperty($name) {
    if($this->$name == null) {

      if(!$this->id) {
        return null;
      }
      
      if($name == "orderproduct") {
        $this->orderproduct = new OrderProduct($this->orderproduct_id);
        return $this->orderproduct;
      }
      
      if($name == "external_finisher") {
        $this->external_finisher = new User($this->external_finished_by);
        return $this->external_finisher;
      }
      
      if($name == "creator") {
        $this->creator = new User($this->create_by);
        return $this->creator;
      }
      
      if($name == "editor") {
        $this->editor = new User($this->edit_by);
        return $this->editor;
      }
      
      $classname = ucfirst($name);
      $idfield = $name."_id";
      $this->$name = new $classname($this->$idfield);
      
      if($this->$name->id) {
        return $this->$name;
      } else {
        return null;
      }
    }
    
    return $this->$name;
  }
  
}