crayon/nova-additional-fields
Composer 安装命令:
composer require crayon/nova-additional-fields
包简介
A Laravel Nova package that allows you to dynamically append inputs to your resources.
README 文档
README
A laravel nova package that allows you to dynamically append inputs to your resources based on a database table.
Installation
composer require crayon/nova-additional-fields
Documentation
Assuming you are building an eCommerce website, and you have different types of products. It would be uncomfortable if you want the admin of the website to enter custom values for each product.
So this package allows you to define form inputs in a Nova resource;
Migration
Product fields (Each field belongs to a category):
Schema::create('product_fields', function (Blueprint $table) { $table->id(); $table->json('text'); $table->string('type'); $table->string('name'); $table->text('options')->nullable(); $table->unsignedBigInteger('category_id'); $table->softDeletes(); $table->timestamps(); $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade'); });
Resource Usage
The additional fields will be loaded from an endpoint (Fields that belong to the category we selected)
AdditionalFields::make('Additional Fields', 'fields') ->parent('category') ->endpoint('/api/category/{category}/fields') ->hideFromIndex(),
Endpoint
Route
Route::get('/category/{category}/fields', [\App\Http\Controllers\Api\NovaHelpers\NovaCategoryController::class, 'fields']);
Controller
/** * Get available fields by Category ID * * @param $category * @return mixed */ public function fields($category) { return Category::findOrFail($category)->fields->map(fn($field) => [ 'id' => $field->id, 'text' => $field->text, 'type' => $field->type, 'name' => $field->name, 'options' => $field->options ]); }
The fields will be loaded into your resource based on the ones you added to your database. ProductFields resource find it here
Screenshots
Conclusion
Laravel Nova is a great piece of software that will boost your productivity when it comes to building admin panels. With a little of customization through custom packages & fields. You are ready to rock 'N roll.
crayon/nova-additional-fields 适用场景与选型建议
crayon/nova-additional-fields 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 153 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 crayon/nova-additional-fields 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 crayon/nova-additional-fields 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 crayon/nova-additional-fields 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
A Laravel Nova Image field. you can paste or drag or chose an image
A Laravel Nova Mail testing tool.
统计信息
- 总下载量: 153
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-22