Skip to content

Commit

Permalink
修复validate没有命名空间问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bai@zhco.com committed Jul 13, 2021
1 parent 62b6fc1 commit 9febaaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/template/impl/ValidateAutoMake.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function make($table, $path, $other)

$model = ucfirst(Utils::camelize($table));
$filePath = empty($path) ? '' : DS . $path;
$namespace = empty($path) ? '\\' : '\\' . $path . '\\';

$prefix = config('database.connections.mysql.prefix');
$column = Db::query('SHOW FULL COLUMNS FROM `' . $prefix . $table . '`');
Expand All @@ -47,6 +48,7 @@ public function make($table, $path, $other)
$ruleArr = VarExporter::export($rule);
$attributesArr = VarExporter::export($attributes);

$tplContent = str_replace('<namespace>', $namespace, $tplContent);
$tplContent = str_replace('<model>', $model, $tplContent);
$tplContent = str_replace('<rule>', '' . $ruleArr, $tplContent);
$tplContent = str_replace('<attributes>', $attributesArr, $tplContent);
Expand Down
2 changes: 1 addition & 1 deletion src/tpl/validate.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace app\validate;
namespace app<namespace>validate;

use nickbai\tp6curd\extend\ExtendValidate;

Expand Down

0 comments on commit 9febaaa

Please sign in to comment.