梅赫梅特·卡恩·萨欣 / blueprint-nova-addon
2.1.0
2023-03-10 15:20 UTC
Requires
- illuminate/pipeline: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- laravel-shift/blueprint: ^1.18 || ^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-10 18:31:18 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)。有关更多信息,请参阅 许可文件。