### Install Filament Barcode Field via Composer Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Install the package via Composer. Requires PHP 8.2 or higher and Filament 5.0. ```bash composer require jeffersongoncalves/filament-barcode-field:^3.0 ``` -------------------------------- ### Use BarcodeInput in Filament Form Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Use the BarcodeInput component in your Filament forms. The example shows a basic usage with a required field. ```php use JeffersonGoncalves\Filament\BarcodeField\Forms\Components\BarcodeInput; // In your form definition BarcodeInput::make('barcode') ->required(), ``` -------------------------------- ### Run Code Analysis and Formatting Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Development commands for running static analysis and formatting code. ```bash # Run static analysis composer analyse # Format code composer format ``` -------------------------------- ### In a Filament Resource Form Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Integrates BarcodeInput into a Filament resource form. Shows the required import and the form method structure. ```php use JeffersonGoncalves\Filament\BarcodeField\Forms\Components\BarcodeInput; public static function form(Schema $schema): Schema { return $schema ->components([ BarcodeInput::make('barcode') ->label('Product Barcode') ->required(), ]); } ``` -------------------------------- ### Publish Translation Files Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Publish the language files to customize translations. Available languages are English (en) and Portuguese (Brazil) (pt_BR). ```bash php artisan vendor:publish --tag=filament-barcode-field-translations ``` -------------------------------- ### Publish Config File Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Publish the package configuration file. The published config file contains settings for asset_js, formats, modal, and reader. ```bash php artisan vendor:publish --tag="filament-barcode-field-config" ``` -------------------------------- ### Namespace declaration Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md The namespace for the package classes. ```php JeffersonGoncalves\Filament\BarcodeField ``` -------------------------------- ### BarcodeFieldServiceProvider registering package assets Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Registers the package configuration, translations, views, and CSS assets via FilamentAsset::register(). The configurePackage method sets the package name and enables config, translations, and views; packageBooted registers assets. ```php class BarcodeFieldServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package ->name('filament-barcode-field') ->hasConfigFile() ->hasTranslations() ->hasViews(); } public function packageBooted(): void { FilamentAsset::register( $this->getAssets(), $this->getAssetPackageName() ); } } ``` -------------------------------- ### Basic Barcode Input Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Basic usage of the BarcodeInput component in a Filament form. Requires the BarcodeInput class import. ```php use JeffersonGoncalves\Filament\BarcodeField\Forms\Components\BarcodeInput; BarcodeInput::make('barcode') ->required(), ``` -------------------------------- ### With Custom Icon Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Adds a custom icon to the BarcodeInput field using the icon method. ```php BarcodeInput::make('barcode') ->icon('heroicon-o-qr-code') ->required(), ``` -------------------------------- ### BarcodeInput class extending TextInput Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Defines the BarcodeInput component that extends TextInput. It sets a custom view, automatically applies a translated placeholder based on the field label, and provides an icon() method to pass an icon name via extra attributes. All standard TextInput methods remain available. ```php namespace JeffersonGoncalves\Filament\BarcodeField\Forms\Components; use Filament\Forms\Components\TextInput; class BarcodeInput extends TextInput { protected string $view = 'filament-barcode-field::components.barcode-input'; protected function setUp(): void { parent::setUp(); $this->placeholder(fn (BarcodeInput $component): string => __('filament-barcode-field::barcode-field.fields.placeholder', [ 'label' => strtolower($component->getLabel()) ]) ); } public function icon(string $icon): static { return $this->extraAttributes(['icon' => $icon]); } } ``` -------------------------------- ### Published Config File for Filament Barcode Field Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/README.md Contents of the published config file. The 'formats' array controls which barcode symbologies the scanner looks for, mapped to the Html5QrcodeSupportedFormats enum from the html5-qrcode library. Restrict it to the symbologies you actually need for faster, more reliable scans. ```php use Filament\Support\Enums\Width; return [ 'asset_js' => 'https://unpkg.com/html5-qrcode@2.3.8/html5-qrcode.min.js', 'formats' => [ 'EAN_13', 'EAN_8', 'UPC_A', 'UPC_E', 'CODE_128', 'CODE_39', 'ITF', 'CODABAR', ], 'modal' => [ 'width' => Width::Large, ], 'reader' => [ 'width' => '600px', 'height' => '600px', ], 'scanner' => [ 'fps' => 10, 'width' => 300, 'height' => 150, ], ]; ``` -------------------------------- ### Restricting Supported Symbologies Source: https://github.com/jeffersongoncalves/filament-barcode-field/blob/3.x/resources/boost/skills/filament-barcode-field-development/SKILL.md Restricts supported symbologies to only EAN codes by editing the 'formats' key in the published config. Useful for retail products. ```php 'formats' => ['EAN_13', 'EAN_8'], ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.