tomatophp/filament-types
Composer 安装命令:
composer require tomatophp/filament-types
包简介
Manage any type on your app in Database with easy to use Resource for FilamentPHP
README 文档
README
Filament Types Manager
Manage any type on your app in Database with easy to use Resource for FilamentPHP
Screenshots
Installation
composer require tomatophp/filament-types
after install your package please run this command
php artisan filament-types:install
finally register the plugin on /app/Providers/Filament/AdminPanelProvider.php
use TomatoPHP\FilamentTypes\Services\Contracts\Type; use TomatoPHP\FilamentTypes\Services\Contracts\TypeFor; use TomatoPHP\FilamentTypes\Services\Contracts\TypeOf; ->plugin(\TomatoPHP\FilamentTypes\FilamentTypesPlugin::make()) ->types([ TypeFor::make('posts') ->label('Posts') ->types([ TypeOf::make('categories') ->label('Categories') ->register([ Type::make('news') ->name('News') ->icon('heroicon-o-newspaper') ->color('#fefefe') ]) ]) ])
Register Type using provider
you can register a type from your provider using our Facade
use TomatoPHP\FilamentTypes\Facades\FilamentTypes; use TomatoPHP\FilamentTypes\Services\Contracts\Type; use TomatoPHP\FilamentTypes\Services\Contracts\TypeFor; use TomatoPHP\FilamentTypes\Services\Contracts\TypeOf; FilamentTypes::register([ TypeFor::make('products') ->label('Product') ->types([ TypeOf::make('sizes') ->label('Sizes') ->register([ Type::make('xl') ->name('XL') ->icon('heroicon-o-adjustments-horizontal') ->color('warning'), Type::make('sm') ->name('SM') ->icon('heroicon-o-adjustments-horizontal') ->color('warning') ]) ]), ]);
Config Locales
You can change the locals within the filament-types config.
- Publish the config file/
- Modify the
localsarray to include the two character language code that applys to the language you wish to offer. EG:
'locals' = ['en'],
Use Type Helper
you can find any type with the helper method to use it anywhere
type_of( key: 'pending', for: 'notes', type: 'groups' );
it will return type model for you.
Use Type Column
you can use type column in your table like this
use TomatoPHP\FilamentTypes\Components\TypeColumn; TypeColumn::make('type') ->for('users') ->type('status') ->allowDescription() ->searchable(),
Auto Caching
on your .env add this
CACHE_STORE=array MODEL_CACHE_STORE=array
supported cache stores are
+ Redis
+ MemCached
+ APC
+ Array
Use Type Base Page
you can create a page for selected type by just extand base type page
use TomatoPHP\FilamentTypes\Pages\BaseTypePage; use TomatoPHP\FilamentTypes\Services\Contracts\Type; class NotesGroups extends BaseTypePage { public function getTitle(): string { return "Notes Groups"; } public function getType(): string { return "groups"; } public function getFor(): string { return "notes"; } public function getBackUrl() { return ManageNotes::getUrl(); // TODO: Change the autogenerated stub } public function getTypes(): array { return [ Type::make('todo') ->name("TODO") ->color('#1461e3') ->icon('heroicon-o-list-bullet'), Type::make('ideas') ->name("Ideas") ->color('#13e0da') ->icon('heroicon-o-sparkles'), Type::make('saved') ->name("Saved") ->color('#29a82e') ->icon('heroicon-o-arrow-down-on-square'), ]; } }
it will be not appear on the navigation menu by default but you can change that by just use this method
public static function shouldRegisterNavigation(): bool { return true; }
Use Type Component
if you like to use a type as a package we create a blade component for you to make it easy to use anywhere on your app like this
<x-tomato-type :type="$type" label="Group" />
User Types Resource Hooks
we have add a lot of hooks to make it easy to attach actions, columns, filters, etc
Table Columns
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeTable; public function boot() { TypeTable::register([ \Filament\Tables\Columns\TextColumn::make('something') ]); }
Table Actions
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeActions; public function boot() { TypeActions::register([ \Filament\Tables\Actions\ReplicateAction::make() ]); }
Table Filters
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeFilters; public function boot() { TypeFilters::register([ \Filament\Tables\Filters\SelectFilter::make('something') ]); }
Table Bulk Actions
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Table\TypeBulkActions; public function boot() { TypeBulkActions::register([ \Filament\Tables\BulkActions\DeleteAction::make() ]); }
From Components
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Form\TypeForm; public function boot() { TypeForm::register([ \Filament\Forms\Components\TextInput::make('something') ]); }
Page Actions
use TomatoPHP\FilamentTypes\Filament\Resources\TypeResource\Actions\ManagePageActions; public function boot() { ManagePageActions::register([ Filament\Actions\Action::make('action') ]); }
Publish Assets
you can publish config file by use this command
php artisan vendor:publish --tag="filament-types-config"
you can publish views file by use this command
php artisan vendor:publish --tag="filament-types-views"
you can publish languages file by use this command
php artisan vendor:publish --tag="filament-types-lang"
you can publish migrations file by use this command
php artisan vendor:publish --tag="filament-types-migrations"
Testing
if you like to run PEST testing just use this command
composer test
Code Style
if you like to fix the code style just use this command
composer format
PHPStan
if you like to check the code by PHPStan just use this command
composer analyse
Other Filament Packages
Checkout our Awesome TomatoPHP
tomatophp/filament-types 适用场景与选型建议
tomatophp/filament-types 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.23k 次下载、GitHub Stars 达 57, 最近一次更新时间为 2024 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「php」 「manager」 「laravel」 「resource」 「types」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tomatophp/filament-types 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tomatophp/filament-types 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tomatophp/filament-types 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
KCFinder web file manager
统计信息
- 总下载量: 19.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 57
- 点击次数: 21
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-10




