PHP code example of laulamanapps / wallet-laravel

1. Go to this page and download the library: Download laulamanapps/wallet-laravel 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/ */

    

laulamanapps / wallet-laravel example snippets




use LauLamanApps\Wallet\MetaData\Barcode;
use LauLamanApps\Wallet\MetaData\BarcodeFormat;
use LauLamanApps\Wallet\Pass;
use LauLamanApps\Wallet\PassType;
use LauLamanApps\Wallet\Wallet;

class TicketController
{
    public function download(Wallet $wallet)
    {
        $pass = new Pass('4de81ef8', PassType::EventTicket, 'LauLaman Apps', 'Concert ticket');
        $pass->addBarcode(new Barcode(BarcodeFormat::Qr, '4de81ef8'));

        // Generate for a single platform
        $generated = $wallet->generate('apple', $pass);

        if ($generated->isFile()) {
            return response($generated->getContent(), 200, [
                'Content-Type' => $generated->getMimeType(),
                'Content-Disposition' => 'attachment; filename="' . $generated->getFilename() . '"',
            ]);
        }

        return redirect()->away($generated->getUrl());
    }
}

foreach ($wallet->generateForAllPlatforms($pass) as $platform => $generated) {
    // $generated->isFile() ? $generated->getContent() : $generated->getUrl()
}

Event::listen(PassInstalledEvent::class, function (PassInstalledEvent $event) {
    // $event->getPlatform(), $event->getPassId(), $event->getNativeEvent()
});



use LauLamanApps\WalletLaravel\WalletServiceProvider;

public function register(): void
{
    $this->app->tag(AcmePassGenerator::class, WalletServiceProvider::PASS_GENERATOR_TAG);
    // or: $this->app->tag(AcmePassGenerator::class, 'wallet.pass_generator');
}

$wallet->generate('acme', $pass);
bash
php artisan vendor:publish --tag=wallet-config