niraj / crudstarter
自动化清洁仪表板的包。
- dev-main
- 7.4.1
- 7.4.0
- 7.3.1
- 7.3.0
- 7.2.0
- 7.1.1
- 7.1.0
- 7.0.0
- 6.1.0
- 6.0.0
- 5.4.1
- 5.4.0
- 5.3.0
- 5.2.0
- 5.1.0
- 5.0.0
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.1
- 4.2.0
- 4.1.12
- 4.1.11
- 4.1.10
- 4.1.9
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.2.3
- 3.2.2
- 3.2.1
- 3.1.1
- 3.0.1
- 3.0.0
- 2.1.2
- 2.1.1
- 2.0.1
- 2.0.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-Niraj
This package is auto-updated.
Last update: 2024-09-22 07:38:07 UTC
README
CRUD和API生成器包
允许您自动化的CRUD操作包。
详细包文档
GO TO DOCS
要求
Laravel Version: >= 8.0
PHP Version: >= 7.3
Composer: >= 2.0
安装
composer require niraj/crudstarter --dev
必需(发布配置文件)
php artisan vendor:publish --tag=crudstarter-config
可选(如果您想编辑占位符文件)
php artisan vendor:publish --tag=crud-stub
生成仪表板(一次性命令)
php artisan gen:dashboard
包使用
基本用法
- 生成CRUD
php artisan gen:crud {模型名} --fields="字段名:数据类型 字段名:数据类型"
- 生成API
php artisan gen:api {模型名} --fields="字段名:数据类型 字段名:数据类型
- 删除CRUD文件
php artisan del:crud {模型名}
- 删除API文件
php artisan del:api {模型名}
示例:生成Post CRUD
php artisan gen:crud Post --fields="name:str slug:str description:text image:str status:bool"
添加字段
您可以在gen
命令中添加字段,它将自动填充model, migration, request 和 api resources
要添加字段,我们使用 --fields="字段名1:数据类型1{空格}字段名2:数据类型2"
示例:生成带有字段的Post CRUD
php artisan gen:crud Post --fields="name:str description:text count:int by_admin:bool is_published:select:options=published,pending"
注意:请在您的ide/text-editor中运行自动对齐(代码格式化)命令在生成的blade文件中[例如:在phpstorm中
Ctrl+Alt+Shift+L
].
添加关系
要添加此功能,只需在gen命令中添加 --relations="你的代码在这里"
示例:生成带有关系的Profile CRUD (hasOne: Account, hasMany: Blogs and belongTo: User)
php artisan gen:crud Profile --fields="name:str user_id:fid" --relations="haso:account hasm:blogs belt:user"
注意:如果您感到舒适,可以直接在 --relations 命令中使用
hasMany
、belongsTo
等,目前它仅支持这四种常见关系类型。
添加软删除功能
要添加此功能,只需在gen命令中添加 --softDelete
示例:生成带有软删除的Post CRUD
php artisan gen:crud Post --fields="name:str description:text" --softDelete
字段数据类型
提供了一些方便的简写,例如,在定义字段时,我们可以用 uint
代替 unsignedInteger
,而不是使用其他数据类型如 date, enum, decimal, uuid
等。
注意:对于其他数据类型,如
date, enum, decimal, uuid
等,可以按原样输入。
将会生成什么!
注意:如果需要,也可以为API生成模型、工厂和迁移。
自定义
- 您可以通过简单地更改位于resources/crud-stub文件夹中的stub文件来轻松地将一切自定义到您的需求。
备注
-
您可能需要轻松地根据您的仪表板模板自定义blade文件。这很容易做到。
-
愉快的编码 🤘