rcoder / crudgenerator
CRUD 生成器
dev-master
2020-11-16 21:32 UTC
This package is auto-updated.
Last update: 2024-09-17 05:40:55 UTC
README
为 Laravel 定制的简单 CRUD 生成器。
入门指南
要开始使用,您应该在项目中添加 rcoder/crudgenerator Composer 依赖项。
composer require rcoder/crudgenerator --dev
Laravel 5.5+ 将自动注册 Rcoder\CrudGenerator\CrudGeneratorServiceProvider 服务提供者。
之后,您需要使用 vendor:publish Artisan 命令发布其资产。
php artisan vendor:publish --provider="Rcoder\CrudGenerator\CrudGeneratorServiceProvider"
用法
您将在 config/crud.php 文件中找到一个配置文件。
在 resources/crud 文件夹中创建您的模型 json 文件,例如 post.json。
{
"model": "posts",
"index": {
"name": "title",
"where": "langs|code|en"
},
"fields": [
{
"name": "title",
"type": "text",
"active": true,
"required": true
},
{
"name": "body",
"type": "textarea",
"wyswig": false,
"required": true
},
{
"name": "photo",
"type": "file",
"required": false
},
{
"name": "published",
"type": "radio"
}
],
"relations":[
{
"model": "langs",
"type": "manytomany",
"select": {
"name": "code"
},
"fields": [
{
"name": "title",
"type": "text"
}
]
},
{
"model": "categories",
"type": "manytomany",
"select": {
"name": "title",
"where": "langs|code|pl"
}
}
]
}
然后使用 Artisan 命令生成。
php artisan crud:generate
您的管理面板位于您的app.com/admin。
版本
这是一个开发版本,未来将添加关系、更多字段类型,并能够创建模型和迁移。
许可证
此项目受 MIT 许可证的许可。