tanthammar/tall-blueprint-addon

2.2.0 2022-11-18 14:50 UTC

This package is auto-updated.

Last update: 2024-09-21 10:36:05 UTC


README

使用 php artisan blueprint:build 命令自动生成所有模型的 TALL-forms

此插件基于 Blueprint Nova Addon,由 Krishan König 开发。

Latest Stable Version Total Downloads Latest Unstable Version

你将获得什么

  • 代码:您获得的代码相当于一个原型/草案。 它不能直接使用。您需要审查并最终确定字段声明。

  • 可用性:您将为每个模型获得一个表单组件。如果您需要分别的创建/更新表单,您可以选择将其拆分为两个组件。

  • 测试:Blueprint 生成的测试与控制器匹配,而不是与 tall-forms 匹配。您必须将它们更新为 Livewire 语法。

  • 重复代码
    您的 draft.yaml 中的任何与 storeupdatedestroy 相关的控制器语句,都将写入控制器和 Livewire 表单组件。为了避免代码重复,您可以在构建命令之后手动从控制器中删除代码。另一个建议是将代码重构到 Actions 中,您可以在控制器和 Livewire 表单组件中使用这些 Actions

    Controller => TallForm,重复代码位置
    • Controller->store() => TallForm->onCreateModel()
    • Controller->update() => TallForm->onUpdateModel()
    • Controller->destroy() => TallForm->onDeleteModel()

  • 赞助商:如果您是赞助商,构建命令将生成赞助字段而不是开源版本。例如,使用 DatePicker 而不是 Input->type('datetime-local')。有关配置选项,请参阅以下内容。

早期版本!

  • 关系字段以 RepeatersSelectsMultiSelect 的形式输出。当我为 TALL-forms 创建必填字段时,这将发生变化。
  • 审查生成的代码,它并不完美 :)

要求

  • tall-forms >= v7.8.4 || v8
  • blueprint >= 1.20

安装

  • 安装 Laravel、Livewire 和 TALL-forms
  • 然后通过 composer 安装此包和 Blueprint
composer require --dev tanthammar/tall-blueprint-addon

配置

您可以使用以下命令发布配置

php artisan vendor:publish --tag=tall_forms_blueprint

赞助商 - 更新配置!

  • 如果您是 tall-forms 的赞助商,发布配置文件并将 sponsor 设置为 true
    构建命令将生成赞助字段而不是开源版本。
    例如,使用 DatePicker 而不是 Input->type('datetime-local')
  • 如果不是,请在此处赞助 tall-forms 包: https://github.com/sponsors/tanthammar
//Do you have access to the tall-forms-sponsor repository?
'sponsor' => true,

时间戳字段

要禁用所有表单的时间戳字段生成,请将此选项设置为 false

用法

请参阅 Blueprint 的基本用法 以开始使用。之后,您可以运行 blueprint:build 命令来自动生成 Tall-forms。尝试此示例 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

controllers:
    Post:
        index:
            query: all
            render: post.index with:posts
        create:
            render: post.create
        store:
            validate: title, content, author_id
            save: post
            dispatch: SyncMedia with:post
            notify: post.author ReviewPost with:post
            send: ReviewPost to:post.author with:post
            flash: post.title
            fire: NewPost with:post
            redirect: post.index
        update:
            update: post
            dispatch: SyncMedia with:post

        destroy:
            flash: post.title
            send: SupportPostDeleted to:support with:post
            delete: post
            redirect: post.index

    Comment:
        resource

贡献

这是一个开源项目,我将乐意接受任何贡献。

鸣谢

许可协议

MIT 许可协议 (MIT)。请参阅 许可文件 获取更多信息。