PHPackages                             matthijs-neijenhuijs/filament-qr-button - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. matthijs-neijenhuijs/filament-qr-button

ActiveLibrary

matthijs-neijenhuijs/filament-qr-button
=======================================

A Filament table column component for displaying QR codes based on record URLs

00PHP

Since Mar 9Pushed 2mo agoCompare

[ Source](https://github.com/matthijs-neijenhuijs/filament-qr-button)[ Packagist](https://packagist.org/packages/matthijs-neijenhuijs/filament-qr-button)[ RSS](/packages/matthijs-neijenhuijs-filament-qr-button/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Filament QR Code Button
=======================

[](#filament-qr-code-button)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9ea151c2c928f949e80d01b6b9f33c0d22c8e32577da609643fd3b715c89626b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61747468696a732d6e65696a656e6875696a732f66696c616d656e742d71722d627574746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matthijs-neijenhuijs/filament-qr-button)[![Total Downloads](https://camo.githubusercontent.com/b15cf18a5ba907239cfc8ee27a0adc83b269c6ea5cf582d2a9998395c3eadb1c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61747468696a732d6e65696a656e6875696a732f66696c616d656e742d71722d627574746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matthijs-neijenhuijs/filament-qr-button)

A powerful Filament table column component that generates QR codes based on URLs in your record data. Built on top of [lara-zeus/simple-qrcode](https://github.com/lara-zeus/simple-qrcode).

[![Filament QR Code Button Demo](https://camo.githubusercontent.com/2a95dec61c75d067a84e48a8543c2892112accc8c7027b62ef2d835e67ca612e/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f383030783430303f746578743d44656d6f2b53637265656e73686f74)](https://camo.githubusercontent.com/2a95dec61c75d067a84e48a8543c2892112accc8c7027b62ef2d835e67ca612e/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f383030783430303f746578743d44656d6f2b53637265656e73686f74)

Features
--------

[](#features)

- 🎯 Generate QR codes from record URLs
- 🎨 Customizable button labels and modal headings
- 📏 Adjustable QR code size
- 🖼️ Multiple format support (SVG, PNG, EPS, PDF)
- 🔒 Error correction level configuration (L, M, Q, H)
- 💬 Modal or inline display modes
- ⚡ Dynamic URL generation using closures
- 🎭 Full Filament theming support

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require matthijs-neijenhuijs/filament-qr-button
```

The package will automatically register its service provider.

### Dependencies

[](#dependencies)

This package automatically installs `lara-zeus/simple-qrcode` which provides QR code generation capabilities.

### Publishing Configuration (Optional)

[](#publishing-configuration-optional)

You can optionally publish the config file:

```
php artisan vendor:publish --tag="filament-qr-button-config"
```

You can optionally publish the views:

```
php artisan vendor:publish --tag="filament-qr-button-views"
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use MatthijsNeijenhuijs\FilamentQrButton\QrCodeColumn;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('name'),

            QrCodeColumn::make('qr_code')
                ->qrUrl('url') // Column containing the URL
                ->buttonLabel('View QR'),
        ]);
}
```

### Dynamic URL Generation

[](#dynamic-url-generation)

```
QrCodeColumn::make('qr_code')
    ->qrUrl(fn ($record) => route('products.show', $record))
    ->buttonLabel('Product QR')
    ->modalHeading('Product QR Code')
```

Configuration Options
---------------------

[](#configuration-options)

> **Note**: We use `qrUrl()` instead of `url()` to avoid conflicts with Filament's built-in `url()` method on table columns, which is used for making the entire column clickable.

### URL Source

[](#url-source)

Define where to get the URL from:

```
// From a database column
QrCodeColumn::make('qr_code')
    ->qrUrl('product_url')

// Using a closure for dynamic URL generation
QrCodeColumn::make('qr_code')
    ->qrUrl(fn ($record) => "https://example.com/track/{$record->tracking_code}")
```

### QR Code Size

[](#qr-code-size)

Set the size of the generated QR code (in pixels):

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->size(200) // Default is 150
```

### Button Label

[](#button-label)

Customize the button text:

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->buttonLabel('Show QR Code')
```

### Modal Configuration

[](#modal-configuration)

Control the modal display:

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->showInModal(true) // Default is true
    ->modalHeading('Scan this QR Code')
```

### Display Inline (Without Modal)

[](#display-inline-without-modal)

Show the QR code directly in the table:

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->showInModal(false)
    ->size(80) // Smaller size for inline display
```

### Error Correction Level

[](#error-correction-level)

Set the QR code error correction level:

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->errorCorrectionLevel('H') // High error correction
```

**Error correction levels:**

- `L` - Low (7% correction)
- `M` - Medium (15% correction) - **Default**
- `Q` - Quartile (25% correction)
- `H` - High (30% correction)

### Output Format

[](#output-format)

Choose the output format:

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->format('svg') // svg, png, eps, pdf (default: svg)
```

Real-World Examples
-------------------

[](#real-world-examples)

### Product URL QR Code

[](#product-url-qr-code)

```
QrCodeColumn::make('product_qr')
    ->label('Product QR')
    ->qrUrl(fn ($record) => route('products.public', $record))
    ->buttonLabel('QR Code')
    ->modalHeading('Product QR Code')
    ->size(200)
    ->errorCorrectionLevel('H')
```

### Order Tracking QR Code

[](#order-tracking-qr-code)

```
QrCodeColumn::make('tracking_qr')
    ->label('Tracking')
    ->qrUrl(fn ($record) => "https://tracking.example.com/{$record->tracking_number}")
    ->buttonLabel('Track')
    ->modalHeading('Track Your Order')
```

### Warehouse Location QR Code

[](#warehouse-location-qr-code)

```
QrCodeColumn::make('location_qr')
    ->label('Location')
    ->qrUrl(fn ($record) => route('warehouse.location', ['location' => $record->location_code]))
    ->buttonLabel('Location QR')
    ->size(150)
```

### Invoice QR Code (Inline Display)

[](#invoice-qr-code-inline-display)

```
QrCodeColumn::make('invoice_qr')
    ->label('Invoice QR')
    ->qrUrl(fn ($record) => route('invoices.download', $record))
    ->showInModal(false)
    ->size(60)
```

Advanced Usage
--------------

[](#advanced-usage)

### Conditional Display

[](#conditional-display)

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->visible(fn ($record) => $record->is_active && $record->url !== null)
```

### Dynamic Button Labels

[](#dynamic-button-labels)

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->buttonLabel(fn ($record) => $record->qr_label ?? 'QR Code')
```

### Dynamic Size

[](#dynamic-size)

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->size(fn ($record) => $record->is_important ? 200 : 150)
```

### Custom Modal Headings

[](#custom-modal-headings)

```
QrCodeColumn::make('qr_code')
    ->qrUrl('url')
    ->modalHeading(fn ($record) => "QR Code for {$record->name}")
```

Complete Example
----------------

[](#complete-example)

Here's a complete example in a Filament resource:

```
