peltonsolutions/filament-enums
Composer 安装命令:
composer require peltonsolutions/filament-enums
包简介
A custom package for Filament for handling enum values in Filament Admin.
README 文档
README
filament-enums is an extension to the peltonsolutions/laravel-enums package, designed specifically for Laravel developers. This package simplifies working with enumerated values in your Filament applications, thus enhancing the readability and maintainability of your code.
Like the laravel-enums package, filament-enums supports the use of named constants, improving the organization and clarity of your code. It leverages the features provided by laravel-enums, complementing them with additional functionalities tailored for Filament.
Optionally, this package allows you to make your Enum fields nullable through the NullableEnum class extension.
Install
You can install the package via composer using the following command:
composer require peltonsolutions/filament-enums
Example:
class ContentPageStatus extends \PeltonSolutions\LaravelEnums\Models\Enum { const DRAFT = 'draft'; const SCHEDULED = 'scheduled'; const PUBLISHED = 'published'; const ARCHIVED = 'archived'; public static function map(): array { return [ static::DRAFT => trans('content_page.statuses.draft'), static::SCHEDULED => trans('content_page.statuses.scheduled'), static::PUBLISHED => trans('content_page.statuses.published'), static::ARCHIVED => trans('content_page.statuses.archived'), ]; } }
class ContentPage extends Model { protected $casts = [ 'status' => ContentPageStatus::class ]; }
class ContentPageResource extends Resource { protected static ?string $model = ContentPage::class; public static function form(Form $form): Form { return $form ->schema([ \PeltonSolutions\FilamentEnums\Models\Forms\Components\EnumSelect::make('status') ->default(ContentPageStatus::DRAFT); } }
This will create a Select component that:
- Gives options from the
map()function - Makes the field required if it's not
\PeltonSolutions\LaravelEnums\Models\NullableEnum - Requires that the selected value matches one of the
map()keys
Testing
To ensure that laravel-enums is functioning correctly, you can run the package's tests using:
NOTE: Tests are WIP. Having troubles writing tests that require the $record to tbe passed into the closures.
composer test
Security
If you discover any security-related issues, please email security@peltonsolutions.com instead of using the issue tracker.
Credits
License
filament-enums is open-sourced software. It's licensed under the MIT license, which is a permissive license allowing the software to be used, modified, and shared.
peltonsolutions/filament-enums 适用场景与选型建议
peltonsolutions/filament-enums 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 166 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「filament」 「peltonsolutions」 「filament-enums」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 peltonsolutions/filament-enums 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 peltonsolutions/filament-enums 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 peltonsolutions/filament-enums 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom package for Filament that provides common enhancements used throughout peltonsolutions packages.
A custom package for Laravel to make it easier to attach and require classes to belong to a tenant.
Alfabank REST API integration
A custom package for Laravel for handling enum values on Models.
A custom package for Laravel to assist with creating BelongsToMany pivot migrations.
Database-driven onboarding for Filament: progress checklists and guided spotlight tours, translatable to any locale.
统计信息
- 总下载量: 166
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-05