承接 nckrtl/filament-resource-templates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nckrtl/filament-resource-templates

Composer 安装命令:

composer require nckrtl/filament-resource-templates

包简介

This is my package filament-resource-templates

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to add the concept of templates to your Filament Resources. By utilizing DTO's to define template sections and components we can apply more structure which is useful when we need to display the content in the frontend through auto completion. This is as well beneficial for Livewire frontends as for Inertia frontends that use typescript.

Use with cause

This package is still considered a work in progress. There are no tests yet and things are still likely to change. So use with caution as future changes might result in data loss when editing records in filament using the template feature of this package.

Installation

You can install the package via composer:

composer require nckrtl/filament-resource-templates

Usage

  1. Prepare your models and tables Each resource you want to use templates for needs at least a template column that can contain a string ($table->string('template')) and content column that will contain the structered content in json format ($table->json('content')). By default all data of your template will be stored in the content column, but if you need data that needs to sit in their own column that's also possible.

In the example below we'll use pages as an example and we'll store the title and slug in a separate column so we can display it more easily in the table on the resource list page.

  1. Create a template file. A template file is basically just a DTO:
namespace App\Filament\Resources\PageResource\Pages\Default;

use App\Filament\Resources\PageResource\Pages\Partials\Sections\TextSectionData;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\Tabs\Tab;
use Filament\Forms\Components\TextInput;
use NckRtl\FilamentResourceTemplates\Template;

class DefaultTemplate extends Template
{
    const NAME = 'Default';

    public string $title;

    public string $slug;

    public static function form()
    {
        return Tabs::make('Label')
            ->tabs([
                Tab::make('General')
                    ->schema([
                        Grid::make(2)->schema([
                            TextInput::make('title')
                                ->placeholder('Titel')
                                ->label('Titel'),
                            TextInput::make('slug')
                                ->placeholder('slug')
                                ->prefix(config('app.url').'/')
                                ->label('slug'),
                        ]),
                    ]),
            ]);
    }
}

Each template at least should have a name and a form definition. In addition you can add sections and properties. When you add class properties that are used in the form definition, then those properties will be stored in their own column. So make sure the columns are added to the table beforehand.

  1. Add sections The form definition in the template is the first section being displayed. You can add additional sections by defining them with a const:
const SECTIONS = [
    TextSectionData::SECTION_KEY => TextSectionData::class,
];

This section is a separate DTO that may look like:

namespace App\Filament\Resources\PageResource\Pages\Partials\Sections;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use NckRtl\FilamentResourceTemplates\TemplateSection;

class TextSectionData extends TemplateSection
{
    const SECTION_KEY = 'text';

    public ?string $text = '';

    public static function form()
    {
        return Section::make('Content')->schema(
            [
                RichEditor::make(static::key('text'))
            ]);
    }
}
  1. Update the class to extend TemplateResource
use NckRtl\FilamentResourceTemplates\TemplateResource;

class PageResource extends TemplateResource
...
  1. Define a list of templates:
public static function getTemplateClasses(): Collection
{
    return collect([
        DefaultTemplate::class,
        ...
    ]);
}
  1. Now when you create a record you should see the template dropdown and the first template will be selected, while showing the form definition defined in the template.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

nckrtl/filament-resource-templates 适用场景与选型建议

nckrtl/filament-resource-templates 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 113 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Nick Retel」 「filament-resource-templates」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nckrtl/filament-resource-templates 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nckrtl/filament-resource-templates 我们能提供哪些服务?
定制开发 / 二次开发

基于 nckrtl/filament-resource-templates 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 113
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-23