Exemplo n.º 1
0
 /**
  * 获取model对象
  * @param string $modelName 名称
  * @return object 返回 instance of BaseModel对象
  */
 public function getModel($modelName = '')
 {
     if (empty($modelName)) {
         $modelName = preg_replace('/Service$/i', '', ClassUtil::getClassName(get_class($this)));
     }
     $modelName = 'App\\Models\\' . ucfirst($modelName);
     if (!class_exists($modelName)) {
         throw new \Exception(get_lang('CLASS_NOT_FOUND', $modelName));
     }
     return new $modelName();
 }