efrontsa / blueprint-nova-addon
v2.0.0
2023-05-09 13:09 UTC
Requires
- illuminate/pipeline: >=9.0
- illuminate/support: >=9.0
- laravel-shift/blueprint: ^2.0
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^4.0 || ^5.0 || ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-09 16:02:01 UTC
README
📣 致谢 Jason McCreary,他的 Blueprint 包为这个小的插件奠定了基础。感谢你,Jason 🙌
安装此插件后,您可以使用 php artisan blueprint:build
命令生成 Nova 资源。
安装
您可以通过 composer 安装此包和 Blueprint。
composer require --dev naoray/blueprint-nova-addon
⚠️ 您需要安装 laravel nova,以便进行资源生成!
用法
请参阅 Blueprint 的基本用法 开始。之后,您可以运行 blueprint:build
命令来自动生成 Nova 资源。为了了解其易用性,您可以使用下面的示例 draft.yaml
文件。
# draft.yaml models: Post: author_id: id foreign:users title: string:400 content: longtext published_at: nullable timestamp relationships: HasMany: Comment Comment: post_id: id foreign content: longtext published_at: nullable timestamp
从这些 13 行 YAML 中,此插件将生成 2 个 Nova 资源,这些资源预先填充了 14 个字段。
// App/Nova/Comment.php public function fields(Request $request) { return [ ID::make()->sortable(), Textarea::make('Content') ->rules('required', 'string'), DateTime::make('Published at'), BelongsTo::make('Post'), DateTime::make('Created at'), DateTime::make('Updated at'), ]; } // App/Nova/Post.php public function fields(Request $request) { return [ ID::make()->sortable(), Text::make('Title') ->rules('required', 'string', 'max:400'), Textarea::make('Content') ->rules('required', 'string'), DateTime::make('Published at'), BelongsTo::make('Author', 'author', User::class), HasMany::make('Comments'), DateTime::make('Created at'), DateTime::make('Updated at'), ]; }
配置
您可以使用以下命令发布配置:
php artisan vendor:publish --tag=nova_blueprint
时间戳字段
要将所有 Nova 资源的时间戳字段生成设置为 false
。
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近的变化。
贡献
请参阅 CONTRIBUTING 了解详情。
安全性
如果您发现任何与安全相关的问题,请通过电子邮件 krishan.koenig@gmail.com 而不是使用问题跟踪器。
致谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。