定制 alkoumi/filament-image-radio-button 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alkoumi/filament-image-radio-button

最新稳定版本:v1.1.7

Composer 安装命令:

composer require alkoumi/filament-image-radio-button

包简介

Filament Form Radio Button But With Images

README 文档

README

RTL & Dark Mode Supported 🎉

Total Downloads Packagist Stars License Latest Version on Packagist GitHub release (latest by date) GitHub Tests Action Status

If you want Filament field to choose and select an Image from a group of images with a Radio button This is Image Radio button to replacing traditional radio buttons with images selection.

filament-image-radio-button.gif

Installation

You can install the package via composer:

composer require alkoumi/filament-image-radio-button

for fiament 4

1- create custom theme Filament Docs

2- then add

@source '../../../../vendor/alkoumi/filament-image-radio-button/resources/views/**/*.blade.php';

to the created theme.

3- Then register the theme in your xxxPanelProvider ->viteTheme('resources/css/filament/main/theme.css')

4- Then npm run build

Important

1- OPTIONS

The radio buttom has options then the scenario Here is you have Model Report and you want to choose a design of a report

so options here must return return Report::pluck('file', 'id')->toArray(); the options will be like

[ 1 => report1.jpg , 2 => report2.jpg] then the user will choose the design.

2- Images

You must define where you stored the images in filesystems disks somthing like local or public so in this example I am using ->disk('reports') So the component can find the images files

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app/private'),
        'serve' => true,
        'throw' => false,
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL') . '/storage',
        'visibility' => 'public',
        'throw' => false,
    ],

    'reports' => [
        'driver' => 'local',
        'root' => storage_path('app/public/reports'),
        'url' => env('APP_URL') . '/reports',
        'visibility' => 'public',
        'throw' => false,
    ],

Usage in basic scenario

use Alkoumi\FilamentImageRadioButton\Forms\Components\ImageRadioGroup;

ImageRadioGroup::make('report_id')
                    ->disk('reports')
                    ->options(fn () => Report::pluck('file', 'id')->toArray()),

Usage in advanced scenario

use Alkoumi\FilamentImageRadioButton\Forms\Components\ImageRadioGroup;

ImageRadioGroup::make('report_id')
                    ->animation(true)
                    ->required()
                    ->label(__('Report Design'))
                    ->disk('reports')
                    ->options(fn (Get $get) => Report::whereType($get('type_id'))->pluck('file', 'id')->toArray())
                    ->afterStateUpdated(fn(Get $get, Set $set, ?string $state) => $set('reportdesign', ['report' => Report::find($state), 'date' => explode(' ', $get('report_date'))[0]])) 
                    ->live(),

Screenshots

filament-plugin-modes.jpg

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.

统计信息

  • 总下载量: 2.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-06