mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进模型在开启class_suffix参数情况下的name属性的识别
This commit is contained in:
@@ -13,6 +13,7 @@ namespace think;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\Query;
|
use think\db\Query;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
@@ -126,7 +127,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
|
|
||||||
if (empty($this->name)) {
|
if (empty($this->name)) {
|
||||||
// 当前模型名
|
// 当前模型名
|
||||||
$this->name = basename(str_replace('\\', '/', $this->class));
|
$name = str_replace('\\', '/', $this->class);
|
||||||
|
$this->name = basename($name);
|
||||||
|
if (Config::get('class_suffix')) {
|
||||||
|
$suffix = basename(dirname($name));
|
||||||
|
$this->name = substr($this->name, 0, -strlen($suffix));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->autoWriteTimestamp)) {
|
if (is_null($this->autoWriteTimestamp)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user