From 763e6b686f55bfa11a948e1994898bcb738dde70 Mon Sep 17 00:00:00 2001 From: Ling Date: Thu, 7 Apr 2022 09:50:38 +0800 Subject: [PATCH] update ModelMakeCommand.php --- app/Console/Commands/ModelMakeCommand.php | 4 ++++ app/Console/Commands/stubs/model.stub | 2 +- app/Models/Model.php | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/Models/Model.php diff --git a/app/Console/Commands/ModelMakeCommand.php b/app/Console/Commands/ModelMakeCommand.php index 17cf476..b59ca88 100644 --- a/app/Console/Commands/ModelMakeCommand.php +++ b/app/Console/Commands/ModelMakeCommand.php @@ -21,6 +21,10 @@ protected function buildClass($name): string '{{classVariable}}' => $classVar, '{{ classVariable }}' => $classVar, ]; + + $serviceNamespace = $this->getNamespace($name); + $replace["use {$serviceNamespace}\Model;\n"] = ''; + return str_replace( array_keys($replace), array_values($replace), parent::buildClass($name) ); diff --git a/app/Console/Commands/stubs/model.stub b/app/Console/Commands/stubs/model.stub index 3bc73cd..7c6c906 100644 --- a/app/Console/Commands/stubs/model.stub +++ b/app/Console/Commands/stubs/model.stub @@ -2,8 +2,8 @@ namespace {{ namespace }}; +use {{ rootNamespace }}Models\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; class {{ class }} extends Model { diff --git a/app/Models/Model.php b/app/Models/Model.php new file mode 100644 index 0000000..754f8a5 --- /dev/null +++ b/app/Models/Model.php @@ -0,0 +1,17 @@ +format('Y-m-d H:i:s'); + } +} -- Gitee