Commit 0be2078e authored by 梁俊杰's avatar 梁俊杰

时间戳问题修复

parent 86353fd0
...@@ -344,9 +344,11 @@ class MakeModelCommand extends HyperfCommand ...@@ -344,9 +344,11 @@ class MakeModelCommand extends HyperfCommand
]; ];
$properties .= " * @property " . (isset($pc[$v['data_type']]) ? $pc[$v['data_type']] : "string") . " $" . $name . ($v['column_comment'] ? " " . $v['column_comment'] : "") . "\n"; $properties .= " * @property " . (isset($pc[$v['data_type']]) ? $pc[$v['data_type']] : "string") . " $" . $name . ($v['column_comment'] ? " " . $v['column_comment'] : "") . "\n";
if ($name == 'created_at' || $name == 'updated_at') { if ($name == 'created_at' || $name == 'updated_at') {
$casts .= "\t\t'" . $name . "'=>'datetime',\n";
$timestamps++; $timestamps++;
} }
if ($name == 'deleted_at') { if ($name == 'deleted_at') {
$casts .= "\t\t'" . $name . "'=>'datetime',\n";
$softDelete = true; $softDelete = true;
} }
if (in_array($name, $filterFields)) { if (in_array($name, $filterFields)) {
...@@ -926,7 +928,11 @@ class MakeModelCommand extends HyperfCommand ...@@ -926,7 +928,11 @@ class MakeModelCommand extends HyperfCommand
$fields[] = "\t\t\t\t'{$name}' => \$faker->time('H:i:s'),"; $fields[] = "\t\t\t\t'{$name}' => \$faker->time('H:i:s'),";
break; break;
case "timestamp": case "timestamp":
$fields[] = "\t\t\t\t'{$name}' => \$faker->unixTime(),"; if ($name == 'created_at' || $name == 'updated_at' || $name == 'deleted_at') {
$fields[] = "\t\t\t\t'{$name}' => \$faker->date('Y-m-d').' '.\$faker->time('H:i:s'),";
} else {
$fields[] = "\t\t\t\t'{$name}' => \$faker->unixTime(),";
}
break; break;
case "year": case "year":
$fields[] = "\t\t\t\t'{$name}' => \$faker->year(),"; $fields[] = "\t\t\t\t'{$name}' => \$faker->year(),";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment