Skip to content

Commit 73f4924

Browse files
committed
support think-orm 4.0
1 parent b32ae65 commit 73f4924

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
}
1010
],
1111
"require": {
12-
"topthink/framework": "^6.0 || ^8.0",
12+
"topthink/framework": "^8.0",
1313
"phpdocumentor/reflection-docblock": "^5.4",
14-
"ergebnis/classy": "^1.1"
14+
"ergebnis/classy": "^1.1",
15+
"topthink/think-orm": "^4.0"
1516
},
1617
"autoload": {
1718
"psr-4": {

src/ModelGenerator.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ public function generate()
156156
*/
157157
protected function getPropertiesFromTable()
158158
{
159-
$properties = $this->reflection->getDefaultProperties();
160-
161-
$dateFormat = empty($properties['dateFormat']) ? $this->app->config->get('database.datetime_format') : $properties['dateFormat'];
162159
try {
163160
$query = $this->model->db();
164161
if ($query instanceof Query) {
@@ -169,20 +166,21 @@ protected function getPropertiesFromTable()
169166
}
170167

171168
if (!empty($fields)) {
172-
foreach ($fields as $name => $field) {
173-
if (in_array($name, (array) $properties['disuse'])) {
174-
continue;
175-
}
169+
$dateFormat = $this->model->getOption('dateFormat');
170+
$createTime = $this->model->getOption('createTime');
171+
$updateTime = $this->model->getOption('updateTime');
172+
$fieldType = $this->model->getOption('type');
176173

177-
if (in_array($name, [$properties['createTime'], $properties['updateTime']])) {
174+
foreach ($fields as $name => $field) {
175+
if (in_array($name, [$createTime, $updateTime])) {
178176
if (false !== strpos($dateFormat, '\\')) {
179177
$type = $dateFormat;
180178
} else {
181179
$type = 'string';
182180
}
183-
} elseif (!empty($properties['type'][$name])) {
181+
} elseif (!empty($fieldType[$name])) {
184182

185-
$type = $properties['type'][$name];
183+
$type = $fieldType[$name];
186184

187185
if (is_array($type)) {
188186
[$type, $param] = $type;

0 commit comments

Comments
 (0)