From 539cf051fc9018ffeb6cf047e2de627fe5c95df4 Mon Sep 17 00:00:00 2001 From: Karson Date: Sat, 2 Mar 2019 08:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E8=BD=AF=E5=88=A0=E9=99=A4=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Menu.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php index a4d2e080..affe0242 100755 --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -192,7 +192,9 @@ class Menu extends Command //判断是否有启用软删除 $softDeleteMethods = ['destroy', 'restore', 'recyclebin']; $withSofeDelete = false; - preg_match_all("/\\\$this\->model\s*=\s*model\('(\w+)'\);/", $classContent, $matches); + $modelRegexArr = ["/\\\$this\->model\s*=\s*model\(['|\"](\w+)['|\"]\);/", "/\\\$this\->model\s*=\s*new\s+([a-zA-Z\\\]+);/"]; + $modelRegex = preg_match($modelRegexArr[0], $classContent) ? $modelRegexArr[0] : $modelRegexArr[1]; + preg_match_all($modelRegex, $classContent, $matches); if (isset($matches[1]) && isset($matches[1][0]) && $matches[1][0]) { \think\Request::instance()->module('admin'); $model = model($matches[1][0]);