level 8
阿左软件定制
楼主
由于项目中使用到的自定义频道,会根据配置自动创建 频道模块的相关文件,有需要的可以借鉴下
public function createFiles($name)
{
$path = root_path();
//controller
$filedir = $path . 'app/admin/controller/';
$model = 'Article' . ucfirst($name);
$table = 'article_' . strtolower($name);
$filename = $model . '.php';
$file = fopen($filedir . $filename, 'w');
$content = "<?php" . PHP_EOL . "namespace app\admin\controller;" . PHP_EOL
. PHP_EOL . "use think\\facade\\Request;" . PHP_EOL
. PHP_EOL . "use app\\common\\facade\MakeBuilder;" . PHP_EOL
. PHP_EOL . "use app\common\builder\FormBuilder;" . PHP_EOL
. PHP_EOL . "use app\common\builder\TableBuilder;" . PHP_EOL
. PHP_EOL . "class {$model} extends Base" . PHP_EOL
. PHP_EOL . "{" . PHP_EOL
. PHP_EOL . "protected \$validate = '{$model}';" . PHP_EOL
. PHP_EOL . "protected \$tableName = '{$table}';" . PHP_EOL
. PHP_EOL . "protected \$modelName = '{$model}';" . PHP_EOL
. PHP_EOL . "}" . PHP_EOL;
fwrite($file, $content);
fclose($file);
}
2024年04月12日 04点04分
1
public function createFiles($name)
{
$path = root_path();
//controller
$filedir = $path . 'app/admin/controller/';
$model = 'Article' . ucfirst($name);
$table = 'article_' . strtolower($name);
$filename = $model . '.php';
$file = fopen($filedir . $filename, 'w');
$content = "<?php" . PHP_EOL . "namespace app\admin\controller;" . PHP_EOL
. PHP_EOL . "use think\\facade\\Request;" . PHP_EOL
. PHP_EOL . "use app\\common\\facade\MakeBuilder;" . PHP_EOL
. PHP_EOL . "use app\common\builder\FormBuilder;" . PHP_EOL
. PHP_EOL . "use app\common\builder\TableBuilder;" . PHP_EOL
. PHP_EOL . "class {$model} extends Base" . PHP_EOL
. PHP_EOL . "{" . PHP_EOL
. PHP_EOL . "protected \$validate = '{$model}';" . PHP_EOL
. PHP_EOL . "protected \$tableName = '{$table}';" . PHP_EOL
. PHP_EOL . "protected \$modelName = '{$model}';" . PHP_EOL
. PHP_EOL . "}" . PHP_EOL;
fwrite($file, $content);
fclose($file);
}