PHP code example of ejoi8 / filament-qr-scanner

1. Go to this page and download the library: Download ejoi8/filament-qr-scanner library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ejoi8 / filament-qr-scanner example snippets


use FilamentQrScanner\FilamentQrScannerPlugin;

return $panel
    ->plugin(FilamentQrScannerPlugin::make());



namespace App\Filament\Resources\Products\Pages;

use App\Filament\Resources\Products\ProductResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use FilamentQrScanner\Tables\Actions\ScanTableSearchAction;
use FilamentQrScanner\Tables\Concerns\InteractsWithScannedTableSearch;

class ListProducts extends ListRecords
{
    use InteractsWithScannedTableSearch;

    protected static string $resource = ProductResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ScanTableSearchAction::make(),
            CreateAction::make(),
        ];
    }
}

use Filament\Forms\Components\TextInput;

TextInput::make('serial_no')
    ->qrScan();

use Illuminate\Support\Str;

protected function normalizeScannedTableSearch(string $code): string
{
    return Str::upper(trim($code));
}