fortytwocoders / crudy
模型与资源CRUD生成器
此包的官方仓库似乎已消失,因此该包已被冻结。
Requires
- php: >=5.5.9
- illuminate/console: >=5.2.
- illuminate/filesystem: >=5.2.
- illuminate/support: >=5.2.
- laravelcollective/html: ^5.4.0
Requires (Dev)
- mockery/mockery: >=0.9.
- orchestra/testbench: >=3.0
- phpunit/phpunit: >=4.0
This package is not auto-updated.
Last update: 2020-12-26 07:58:18 UTC
README
此包添加了php artisan crudy命令,用于
- 创建带有属性模型的模型
- 为该模型创建迁移
- 创建带有索引、显示、编辑、更新、创建、存储和删除方法的控制器,并将它们映射到相应的视图
- 为该模型创建并附加路由到路由文件
- 为指定的模型创建视图(显示、创建、索引、编辑)
此包的基础是@amochohan laravel-make-resource(https://github.com/amochohan/laravel-make-resource),所以向他也致以崇高的敬意。我们需要一个这样的包来用于我们的项目,所以我们采用了他已非常出色的包,为最新的Laravel版本进行了更新,并添加了一些我们需要的特性。
安装
通过Composer安装Crudy
"require-dev": {
"fortytwocoders/crudy": "~0.2"
}
更新config/app.php文件以添加包含的服务提供者
'providers' => [
/*
* Package Service Providers...
*/
FortyTwoCoders\Crudy\CrudyServiceProvider::class,
];
到此为止,包现在可以使用了。
此包需要
"laravelcollective/html": "^5.4.0"
用于在视图中构建表单
使用Crudy
从命令行运行
php artisan crudy ModelName "model attributes"
基本示例为:php artisan crudy Test
此命令将创建以下文件
app/Http/Test.php
app/Http/Controllers/TestController.php
database/migrations/2017_12_12_102938_create_tests_table.php
resources/views/tests/index.blade.php
resources/views/tests/create.blade.php
resources/views/tests/show.blade.php
resources/views/tests/edit.blade.php
并将此模型的路由附加到
routes/web.php
(不必担心,它不会覆盖您已保存的现有路由)
具有属性示例:
php artisan crudy Test "name:string,fillable|age:integer,fillable,unsigned|email|city:hidden"
当您想要传递属性时,请以管道分隔的列表进行: {属性名}:{逗号分隔的属性} | {第二个属性名}:{第二个属性属性} | 以此类推...
如果您指定了fillable
或hidden
,则属性将相应设置,如果您没有提供,则属性不会被添加。另外,如果您没有为属性提供数据类型,它们将自动转换为字符串类型。