alkoumi / filament-image-radio-button
Filament Form Radio Button But With Images
Fund package maintenance!
alkoumi
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- pestphp/pest-plugin-livewire: ^2.1|^v3.0.0
README
RTL & Dark Mode Supported 🎉
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.
Installation
You can install the package via composer:
composer require alkoumi/filament-image-radio-button
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 => reort1.jpg , 2 => reort2.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 (Get $get) => Report::whereType($get('type_id'))->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
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.