PHP code example of aiarmada / filament-vouchers

1. Go to this page and download the library: Download aiarmada/filament-vouchers 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/ */

    

aiarmada / filament-vouchers example snippets


use AIArmada\FilamentVouchers\FilamentVouchersPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentVouchersPlugin::make(),
        ]);
}

// config/filament-vouchers.php
return [
    // Navigation group for resources
    'navigation' => [
        'group' => 'Vouchers & Discounts'
    ],

    // Default currency for monetary displays
    'default_currency' => 'MYR',

    // Table polling interval (seconds or null to disable)
    'polling_interval' => 60,

    // Resource navigation ordering
    'resources' => [
        'navigation_sort' => [
            'vouchers' => 40,
            'voucher_usage' => 41,
        ],
    ],

    // Order resource for linking (set class-string or null)
    'order_resource' => null,

    // Owner types for multi-tenant voucher assignment
    'owners' => [],
];

use AIArmada\FilamentVouchers\Extensions\CartVoucherActions;

protected function getHeaderActions(): array
{
    return [
        CartVoucherActions::applyVoucher(),
        CartVoucherActions::showAppliedVouchers(),
    ];
}

// config/filament-vouchers.php
'owners' => [
    [
        'label' => 'Store',
        'model' => App\Models\Store::class,
        'title_attribute' => 'name',
        'subtitle_attribute' => 'email',      // Optional
        'search_attributes' => ['name', 'code'],
    ],
    [
        'label' => 'Vendor',
        'model' => App\Models\Vendor::class,
        'title_attribute' => 'company_name',
        'search_attributes' => ['company_name', 'email'],
    ],
],
bash
php artisan vendor:publish --tag=filament-vouchers-config