From da554dc56a2e4a9faedbadc7d1ff0b53e81d071d Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sun, 11 May 2025 15:30:21 +0800 Subject: [PATCH] command ResourceFill --- README.md | 2 +- app/Admin/Controllers/UserController.php | 2 +- app/Console/Commands/ModelFillable.php | 2 +- app/Console/Commands/ResourceFill.php | 45 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 app/Console/Commands/ResourceFill.php diff --git a/README.md b/README.md index 48cd42f..03cd96b 100644 --- a/README.md +++ b/README.md @@ -78,5 +78,5 @@ public function update($primaryKey, $data) ## TODO -- 表单验证: 服务端返回 `errors` 不生效, 示例文件: `app\Services\UserService.php`, [组件文档](https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%A0%A1%E9%AA%8C) +- 表单验证: 服务端返回 `errors` 错误信息, 未在输入框上显示, 示例文件: `app\Services\UserService.php`, [组件文档](https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%A0%A1%E9%AA%8C) - CURD 组件: 如果存在 `bulkActions` 按钮时, 表格会出现滚动条 \ No newline at end of file diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index a6c6572..2ae7edb 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -22,7 +22,7 @@ class UserController extends AdminController ->headerToolbar([ $this->createButton('drawer', 'lg')->permission('admin.users.create'), ...$this->baseHeaderToolBar(), - $this->exportAction(), + $this->exportAction(true), ]) ->bulkActions([ // $this->bulkDeleteButton()->permission('admin.users.delete') diff --git a/app/Console/Commands/ModelFillable.php b/app/Console/Commands/ModelFillable.php index c193e33..50c4e56 100644 --- a/app/Console/Commands/ModelFillable.php +++ b/app/Console/Commands/ModelFillable.php @@ -19,7 +19,7 @@ class ModelFillable extends Command * * @var string */ - protected $description = 'get model fillable '; + protected $description = 'print model fillable '; /** * Create a new command instance. diff --git a/app/Console/Commands/ResourceFill.php b/app/Console/Commands/ResourceFill.php new file mode 100644 index 0000000..89e6eb6 --- /dev/null +++ b/app/Console/Commands/ResourceFill.php @@ -0,0 +1,45 @@ +argument('name'); + $columns = []; + if (class_exists("App\\Models\\{$name}")) { + $model = app("App\\Models\\{$name}"); + $columns = $model->getFillable(); + } + if (Schema::hasTable($name)) { + $columns = Schema::getColumnListing($name); + } + if (count($columns) <= 0) { + return $this->error("{$name} 不存在"); + } + foreach($columns as $key) { + $this->info("'{$key}' => \$this->{$key},"); + } + } +}