razorsheep/blueprint-nova-addon

资助包维护!
Naoray

0.0.1 2023-05-15 12:27 UTC

This package is not auto-updated.

Last update: 2024-10-01 17:07:05 UTC


README

Build Status Total Downloads

📣 致力于 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)。请参阅 许可证文件 了解更多信息。